Prevent Powershell ForEach from Adding Superfluous Quotes -


i have colon-delimited csv so,

mailbox:users acmecorp:("jsmith","trex") xyzcorp:("sjobs","bfranklin") 

it added variable:

$file = import-csv file.csv -delimiter : 

now, work it:

foreach ($record in $file) {     $record.users | % { get-aduser $_ } } 

write-host in foreach loop reports $record.users ("jsmith","trex")

however, get-aduser (or other cmdlets) complains cannot find object identity '("jsmith","trex")'.

how prevent foreach adding single quotes parameter?

i've tried users "sjobs","bfranklin" import-csv strips double quotes off of sjobs

or better, how pass list of users foreach?

powershell version 4

the quotes not being added ps. right there in file. here snippet give start in right direction:

$file = import-csv file.csv -delimiter ':' foreach($row in $file){     foreach($user in $row.users.split(',')){         get-aduser ($user.replace('(','').replace('"','').replace(')',''))     } } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -