3

Using the active directory module I need to Get-ADComputer of all the computers in an specific OU and list all their properties.

I tried something like this:

Get-ADComputer -Filter 'DistinguishedName -like "*OU=Testing*"'
mkrouse
  • 41
  • 1
  • 1
  • 6

1 Answers1

4

What you are looking for (and probably could have found on your own if you had done a simple get-help get-adcomputer -detailed) is the -SeachBase option for that command. Since you only want one specific OU you may want to use the -SearchScope option as well.

Get-ADComputer -searchbase "OU=Testing,CN=Some,CN=Domain,CN=Com" -SearchScope 0 -Filter *

Obviously you will need to change the path of the SearchBase to suite your needs.

TheMadTechnician
  • 34,906
  • 3
  • 42
  • 56
  • For me, using PowerShell v4, the `-filter` option is still required. So `Get-ADComputer -SearchBase "OU=Testing,DC=contoso,DC=com" -Filter *` should work. – Signal15 Nov 19 '18 at 21:20
  • 1
    @Signal15 You are quite right, this was written years ago, and evidently I missed that when I wrote the answer. I'll update it to include that, thanks for catching it! – TheMadTechnician Nov 19 '18 at 22:34