for other processes I want to split the following line into objects. The Line is from our Exchange Incomming SMTP Logfile.
2014-05-23T08:38:58.869Z,Exchangeserver\External Relay,08D1437A9AEFF27B,5,192.168.100.211:25,192.168.100.211:46964,<,MAIL FROM: <[email protected]>
Is it possible to do this with regular expressions?
Desired Output:
Time: 08:38:58
Connector: Exchangeserver\External Relay
ExchangeID:08D1437A9AEFF27B
MailFrom:[email protected]
I´m sorry, but regular expressions are to heavy for my brain.. :(
Thanks a lot!
You only need regex for email addres. You can split columns with, well, -split
:)
$arr = @("2014-05-23T08:38:58.869Z,Exchangeserver\External Relay,08D1437A9AEFF27B,5,192.168.100.211:25,192.168.100.211:46964,<,MAIL FROM: <[email protected]> " -split ",")
$ht = [ordered]@{}
$ht["Time"] = $arr[0]
$ht["Connector"] = $arr[1]
$ht["ExchangeID"] = $arr[2]
$ht["MailFrom"] = $($arr[7] -match "([^=@]+@[^>]+)" | Out-Null; $matches[1])
$ht
You can then format the results from hashtable to get your desired output.