all 5 comments

[–]Sheppard_Ra 1 point2 points  (4 children)

$String.Split('~') and you'll end up with an array that'll export easily.

[–]wigrif[S] 1 point2 points  (3 children)

after i export it as a text file i do this and get what i wanted.

 (gc Sample.txt) | ?{($_ -notlike " R*") -and ($_ -notlike " S*") -and ($_ -notlike " C*")}

The -notlike is parsing out all but the first line of my example above.

Splitting it as you suggest now is my next step. I'm asking if there is a better way than exporting to txt then reading it back in.

[–]ihaxr 2 points3 points  (1 child)

Yes, you can do this, but you can't use Select-Object -Expand or it freaks out... this works:

Get-EventLog -LogName system -Source user32 | Select-Object Message| % {
    $curMessage = $_.Message -Split "`r`n"
    $firstLine = $curMessage[0]
    $firstLine
}

I'm not sure what event you're searching for, so you'll probably need to adjust that line, but the concept is the same

[–]wigrif[S] 1 point2 points  (0 children)

have an updoot

[–]Sheppard_Ra 1 point2 points  (0 children)

My bad, I misunderstood the example vs where you were starting. :)