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

string manipulation

$
0
0

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.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles