Hi Guys,
Heres a little segment from a script Im writing;
Get-Content $tempDir\$todaysLog | Where-Object { $_ -match "" } |
ForEach-Object -Process {
$fields = [regex]::split($_,'@|\s+')
Add-Content -Path $importSource2\$todaysLog -value ($($fields[0]) + "`t" + $($fields[1]) + "`t" + $($fields[2]) + " " + $($fields[3])+ "`t" + "<*sender*@"+($($fields[5])) + "`t" + "<*recipient*@"+($($fields[7])))
}
Sorry about the wrapping, essentially it tokenises the elements of the file into an an array then writes out certain elements with some other text around it. The purpose is to replace sentitive sender/recipient information with something meaningless.
heres a sample of the logfile I'm parsing;
10.197.71.28 SG 02012009 00:00:00 [email protected] <['[email protected]']>
Obviously Ive replaced the address info in my sample. The above segment works just fine althgogh Im conscious its very expensive. Can anything think of something that would be less expensive, perhaps a select-string to replace the text rather than tokenising/rewriting it?
Cheers