I'm trying to modify or replace text in a string, which seems to me, it should be fairly east to do. But examples I've seen and read about appear to go off in other directions or end up with results I'm not looking for!
In short, I have an xls and I took one column and saved it in a txt file. The file is a list of users names BUT it is [lastname,firstname .middleInitial]. (less the square brackets) the space dot middleinitial is only a few names.
My goal is to add the users to an AD group. It seems to me this should be easy, but all I've ever gotten is either errors (that easy enough to get) or, a new text file with each name on a separate line,
firstname
lastname
middlename
to feed into a new comlet to add to a group, I think my best option, and what I'm trying to achive, is to get a new text file that rearranges each line of the file with [firstname lastname or firstname middleinitial lastname] with no punctuation, on each line.
I've tried..
get-content 'C:\Temp\textfile.txt' [regex]::Split([a-z]),([a-z]) $2,$1
what I get is unexpected token ')' in expression or statement.
my understanding of what is supposed to happen here, is textfile.txt is read, then each line is read and split at the first comma, the two parts are then stored as $1 and $2. since I want $2 first (the first name and middle initial if there is one) I put it ($2) first followed by $1 the last name.
Can anyone put me on the correct path, for what I want to do? which is get each line of the file to list first name middle initial last name all on a single line. From that I believe I can feed the string into a comlet to add the user to an AD group.
Thank you
Blue in AZ