Get all active directory computers from all domains

Rob M 61 Reputation points


I need to get all Active Directory computers from five different domains. The script below has executed without errors except for one domain. This is the code I am using:

Get-ADComputer -Filter * -Properties * -Server ""  | Select-Object Name

This is the error I am seeing:

Get-ADComputer : Directory object not found
At line:1 char:1
+ Get-ADComputer -Filter * -Properties * -Server ""   ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-ADComputer], ADIdentityNotFoundException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Comm 

I get that the error message says the Directory object is not found but without changing anything but the server name, the script is working fine in the other domains.

Thank you!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,429 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,416 Reputation points

    Is a Global Catalog Server? If it is, use "" instead of just the server name. You'll probably have to add a -SearchBase to the cmdlet, too. The value of that should be the root domain of the AD forest. That should search ALL domains in the AD forest.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rob M 61 Reputation points

    I made one change and it seems to be working now:

    Get-ADComputer -Filter * -Properties Name -Server ""  | Select-Object Name

    I added in the name of a property before the pipe, Name.

    The other domains didn't need anything other than -Properties *. Why is this domain different?


    0 comments No comments