Friday, July 14, 2017

Find All Servers in OU Utilizing dsquery

Recently at work I needed to pull all servers from a specific OU and Get-ADComputer was not working for some reason.  I didn't feel like taking the time to figure it out so I just reverted back to handy dsquery:

dsquery * OU=Test,DC=contoso,DC=local -scope subtree -limit 999999999 -filter "(&(objectClass=Computer)(objectCategory=Computer))" -attr sAMAccountName operatingSystem

No comments:

Post a Comment