How to get a list of OUs in AD using PowerShell scripts

Retrieving a list of OUs in helps administrators audit directory structure, verify delegation boundaries, and maintain an organized environment. The following is a comparison between retrieving a list of OUs in an AD domain using Windows PowerShell and ADManager Plus, a comprehensive AD reporting tool.

Windows PowerShell

Steps to obtain list of OUs in AD using PowerShell:

  • Identify the domain from which you want to retrieve the report.
  • Identify the LDAP attributes you need to fetch the report.
  • Compile the script.
  • Execute it in Windows PowerShell.
  • The report will be exported in the given format.
  • To obtain the report in a different format, modify the script accordingly to the needs of the user.

Sample Windows PowerShell script

 Copied
Get-ADOrganizationalUnit -Filter'Name -like "*"' | Format-Table Name, DistinguishedName -B
Click to copy entire script

ADManager Plus

To obtain a report:

  • Select All OUs from OU Reports -> Reports tab.
  • Select the domain and click Generate.
  • Select Export as to export the report in any of the preferred formats (CSV, PDF, HTML, CSVDE and XLSX).

Screenshot

» Start 30-day Free Trial

Limitations:

  • We can run this script only from the computers which has Active Directory Domain Services role.
  • Adding even minor modifications to a script—such as adding additional attributes to the reports—require it to be modified and executed again, which is time-consuming.
  • For each format type, a script has to be modified accordingly to export in that format, leading to increased LDAP query complexity in these scripts.
  • Troubleshooting these scripts requires extensive AD and scripting expertise.

ADManager Plus will retrieve details of OUs in any desired format in a simple and intuitively designed UI.

Schedule and export reports on AD objects, including OUs, without PowerShell scripting.

  Get 30-day free trial.

Embark on your script-free AD management, reporting, and automation journey with ADManager Plus.

  •  
     
  • By submitting you agree to processing of personal data according to the Privacy Policy.

Thanks

Your download should begin automatically in 15 seconds. If not, click here to download manually.

Related Powershell How-to Guides:

The one-stop solution toActive Directory Management and Reporting

Email Download Link Email the ADManager Plus download link