List AD Organizational Units with Powershell

Here’s a quick Powershell one-liner to list all the Organizational Units, or OUs, in your Active Directory domain. Firstly you’ll probably need to load the ActiveDirectory module. This can be done at the Powershell prompt with the below command;

?View Code POWERSHELL
Import-Module ActiveDirectory;

Then we can use the Get-ADOrganizationalUnit cmdlet to retrieve a list of OUs.

?View Code POWERSHELL
Get-ADOrganizationalUnit -Filter * | Select-Object -Property Name | Format-Table -AutoSize;

This will display a list looking something like below;

Name
----
Domain Controllers
Microsoft Exchange Security Groups
Security Groups
Domain Servers
Domain Workstations
Domain Guest Accounts
Printers
Management
Virtual Desktops
IT
Service Accounts
Users
Computers
Production Servers
SQL Servers
Web Servers

Leave a Reply