Wednesday, December 19, 2012

PowerShell: List users from a specific OU

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

Import-Module Active Directory
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.

No comments:

Post a Comment

Followers

hit counter