Share via


How to Get a List of All Users from a Specific OU with PowerShell

The rules and settings configured for an organizational unit (OU) in Microsoft Active Directory (AD) apply to all members of that OU, controlling things like user permissions and access to applications. Therefore, it’s critical to keep a close eye on the membership of every OU on your domain DC, especially powerful ones like your Managers OU.

1. Open the Powershell ISE → Run the following script, adjusting the OU and export paths:

$OUpath = 'ou=Managers,dc=enterprise,dc=com'
$ExportPath = 'c:\data\users_in_ou1.csv'
Get-ADUser -Filter * -SearchBase $OUpath | Select-object
DistinguishedName,Name,UserPrincipalName | Export-Csv -NoType $ExportPath

 2. Open the file produced by the script in MS Excel.
https://img.netwrix.com/howtos/users_in_ou.png

 Originally posted: https://www.netwrix.com/how_to_get_all_users_from_a_specific_ou.html