Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

get 2 items from select-string

$
0
0

Hi,

I'm stuck trying to get the output looking right. Here's my SLS line:

(Sls \\server1\logs$\DomainLogins\Date.txt -pattern username | % {($_ -split ",")[0,4]-join ','}).Split("`n").Replace("\\server1\logs$\DomainLogins\Date.txt:",$Null).Replace(":.",$Null).Trim() | get-unique

This returns:

26408:username1, machinename2

33096:username2, machinename2

I need to remove the numbers and semi-colon prior to the username so it looks like:

username1, machinename1

username2, machinename2

I'm really just trying to remove the filename and line number from select-string. 

What's the best approach?

Viewing all articles
Browse latest Browse all 6937

Trending Articles