Sunday, November 15, 2015

Get-ADComputer - list and return the computers matching the query


Command to obtain the list of computers in a specified AD OU - could be done with Get-ADUser as well probably.

Get-ADComputer -filter * -SearchBase "OU=Live,OU=Laptops,OU=Physical,OU=Desktops,OU=1,DC=name2,DC=name1,DC=local" | select name | sort name

In the above command if you replace the sort name with measure the output will count the total number of items and return that as the count.