I have this code that will remote white spaces from the end of each line of a .txt file.
$content=Get-Content"C:\Temp\List.txt"
$content | Foreach {$_.TrimEnd()} | Set-Content"C:\Temp\List2.txt"
But how would I do the following.
Brown, John T
Kim, Mary R
Smith, Steven P
How would I remove the middle initial? I need just Brown, John with no white spaces after John.
I was given a list of user names but they were not from AD. Each name has the middle initial but we don't use the middle initial in AD. It is a really long list too, over 1,600 names so I don't want to do it manally.