PowerShell: List users from a specific OU


Here is the command to list all users from specific OU in Active Directory.

Import-Module ActiveDirectory
Get-ADUser -Filter * -SearchBase “ou=ouname,dc=company,dc=com”

If you don’t know the OU name in distinguished name,

1. open Active Directory Users and Computers, enable Advanced Features in the menu, open the OU properties, go to Attribute Editor and open distinguishedName property and Select the OU distinguished name, copy/paste it to the above Get-ADUser command.

OR

2. Type this command: Get-ADOrganizationalUnit -Filter * | Select-Object DistinguishedName. Select the OU distinguished name, copy/paste it to the above Get-ADUser command.

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s