In this guide, you will learn how to get a list of users from an OU using PowerShell and the AD Pro Toolkit. I’ll also show you how to find the distinguishedName of an OU as this is required when using PowerShell.
Video Tutorial
List All Users from an OU with PowerShell
In this example, I’ll use PowerShell to list all users from a specific OU.
Step 1. Open PowerShell
Step 2. Copy and paste the command below. You will need the distinguishedName of the OU, see details below.
get-aduser -filter * -searchbase "OU=Purchasing,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" | select name, DistinguishedName
Get Users in OU and Sub OU
To list all users in an OU and sub OUs and -SearchScope subtree to the command.
get-aduser -filter * -searchbase "OU=Purchasing,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" -SearchScope subtree | select name, DistinguishedName
How to Get the DistinguishedName of OU
To list users from an OU you need its distinguishedName. Open Active Directory Users and Computers (ADUC) browse to the OU, right-click the OU, and select properties.
Click on the “Attribute Editor” and copy the distinguishedName value.
If you do not see the Attribute Editor tab you need to turn on “Advanced Features” from the view dropdown.
List All Users from a Single or Multiple OUs with the AD Pro Toolkit
The AD Pro Toolkit is a collection of Active Directory Tools that simplifies managing Active Directory. With the built-in reporting tool, you can easily get a list of users from a single OU, multiple OUs, or groups.
Step 1. Open the AD Pro Toolkit.
Step 2. Click on User Reports – > All users
Step 3. Click Browse to select one or more OUs
Step 4. Click Run
To add or remove user attributes click the column button.