How to List All Computers in an OU

{{ firstError }}
We care about security of your data. Privacy Policy
Native Auditing Netwrix Auditor for Active Directory
Native Auditing
Netwrix Auditor for Active Directory
Steps
  1. Open the Powershell ISE → Run the following script, adjusting the OU and path for the export:

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

  1. Open the file produced by the script in MS Excel.
List of All Computers in an OU report produced by the script in MS Excel
  1. Run Netwrix Auditor → Navigate to "Reports" → Expand the "Active Directory" section → Go to "Active Directory - State-in-Time" → Select "Computer Accounts" → Click "View".
  2. Specify the "Path" filter (e.g., "%Managers%" for the "Managers" organizational unit) → Click "View Report".
  3. To save the report, click the "Export" button → Choose a format from the dropdown menu → Click "Save".
Netwrix Auditor Computer Accounts Report: shows computer accounts with the path and status

Tired of Running PowerShell Every Time You Need to Get Computers in an OU Listed?

Have you ever needed to find all computer accounts in a specific OU? You can try using Active Directory Users and Computers, but it is slow and inflexible. Another way to go is firing up PowerShell, loading the Active Directory PowerShell module and writing a script.  When you need to retrieve a list of computer names, Get-ADComputer is the most useful cmdlet. You might want to restrict the output of your query by using –Filter and specifying the target OU via –SearchBase. And don’t forget to use Write-Host to make your report that much special! Add Export-Csv at the end, run the script, and then open the resulting csv file to examine the results of the commands you just wrote.

This looks like too much trouble just to get a list of computers in an OU. If you’re constantly pressed for time and have more important tasks on your plate, why don’t you automate the process of inventorying computer accounts with Netwrix Auditor for Active Directory? Its easy-to-read reports simplify routine tasks like finding all computer objects in your domain. You can filter the report to show only enabled (or only disabled) OU computers. If you need more detailed information about Windows Server computers in your network, you might want to take a look at Netwrix Auditor for Windows Server. It lists operating system versions, local users and groups, installed programs and other configuration properties, and even highlights possible security issues, such as an outdated OS or improper antivirus.

Related How-tos