0

I am setting up an application that have rooms for its users. The only way to group these users is by listing their names in the following fashion:

Host IN ('Fist1 Last1', 'Fist2 Last2', 'Fist3 Last3')

I would like to output the names of the users in a given OU in the format inside of the parentheses above. Just 'Fist1 Last1', 'Fist2 Last2', 'Fist3 Last3'.

Get-ADuser -searchbase "OU=HQ,DC=DOMAIN,DC=COM" -filter {enabled -eq "True"} | Select-Object -Property name

How can I have that output in 'first last', 'first last', 'first last', etc....

Thanks!

1 Answer 1

1

Not tested, but I think this should work:

(Get-ADuser -searchbase "OU=HQ,DC=DOMAIN,DC=COM" -filter {enabled -eq "True"} |
  ForEach-Object { "'{0} {1}'" -f $_.GivenName,$_.Surname }) -join ','
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.