How to get a list of OUs in AD using PowerShell scripts
The following is a comparison between obtaining a list of OUs in AD with Windows PowerShell and ADManager Plus:
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.