How to get a list of computer objects in an active directory OU ( tested against Windows 2016 Active Directory )
A quick PowerShell script using Get-ADComputer command, a wild card filter and a search base pointing to a specific OU
First import modules for active directory in powershell
Copy and edit the script below:
## cmd
## dsquery computer -name servername (server name in the OU to get the OU path)
#Example lists domain controller in test.com
#Export list of names to CSV
Get-ADComputer -Filter * -SearchBase “OU=Domain Controllers,DC=test,DC=com” | Select Name | export-csv C:\temp\DCs.csv
( Like the post click and advert of interest to give us support)