Reputation: 2329
I have a powershell command that lists usernames and displays within a OU. When I run the following
$cs = get-aduser @ADUserParams | select-object @SelectParams
write-host $cs.DisplayName "," $cs.SAMAccountname
The results are not in the expected format:
Bob Leyland Sam Leyland , bob.leyland sam.leyland
I have tried to pass this through a loop but receive the same line twice. Out of my depth here.
I would like
Bob Leyland,bob.leyland
Sam Leyland,sam.leyland
Upvotes: 0
Views: 27
Reputation: 22831
Pipe the command to ForEach-Object
or %
for its shorthand alias:
$cs = get-aduser @ADUserParams | select-object @SelectParams | % { write-host "$($_.DisplayName) , $($_.SAMAccountname)" }
Upvotes: 2