Forum Discussion
Using Get-ADComputer Syntax
Hello all,
I am attempting to gain inventory on newly installed SSD drives in workstations. When I use "get-adcomputer" and use "-filter *" does this grab computers listed in all domain controllers or just one particular DC?
Thanks.
2 Replies
- LainRobertsonSilver Contributor
Active Directory is a multi-master directory service. This means that all domain controllers hold exactly the same information (allowing for minor variations where inter-site replication takes place).
It does not matter which domain controller you run your query against, they will return the same result set.
If you're in a forest with more than one domain, the domain queried will be governed by the defaultNamingContext associated with your computer's account. You can verify this value with the following PowerShell command:
([adsi]"LDAP://RootDSE").defaultNamingContextAs per AndySvints' comment, you can override this default search location using a combination of -SearchBase, -SearchScope and -Server.
Note: If you are in a multi-domain forest, searching the forest root will not allow you to discover computers in the child domains (by default). You can get around this by specifying that you wish to run your search against a global catalog server (GC) but this comes with the trade off that not all the class' attributes are available in such a search.
- AndySvintsIron Contributor
Hello tylerjohnson0526,
AFAIK it grabs the list of computers in Active Directory Forest (All DCs).
In your command you are not specifying SearchBase and Server parameters.
From the help & documentation of -SearchBase:
"the default value of this parameter is the default naming context of the target domain."
Help & documentation of -Server:
"The default value for this parameter is determined by one of the following methods in the order that they are listed:
- By using the Server value from objects passed through the pipeline
- By using the server information associated with the Active Directory Domain Services Windows PowerShell provider drive, when the cmdlet runs in that drive
- By using the domain of the computer running Windows PowerShell"
Hope that helps.