0

I need to create CSV file containing all my users from AD. I'll be creating gsuite addresses for each user from this domain. Google needs only their name, surname email address and password. I will compose mail like this [first letter of the name and surname]@mydomain.com. The only problem i have is with powershell. I'm trying to use Select-ADuser cmdlet to get this jobe done. This is my basic query:

Get-AdUser -Server $server -filter {(ObjectClass -eq "user") -and (enabled -eq $true)}

It returns users I want but with things I don't need like "HealthMailbox". My domain follows the agdlp rules so it shouldn't be that hard to retrieve the users. Only question is how can I specify OU I want to retrive my users from?

1 Answer 1

3

Only question is how can I specify OU I want to retrive my users from?

Use the SearchBase parameter:

Get-ADUser -SearchBase 'OU=ActualUsers,DC=domain,DC=tld' -Filter {(ObjectClass -eq "user") -and (enabled -eq $true)} -Server $server
Sign up to request clarification or add additional context in comments.

1 Comment

The (ObjectClass -eq "user") isn't necessary at all. It would be necessary if you were using Get-ADObject, but Get-ADUser already has that filter baked in.

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.