This article is a very brief example of how to use dsquery/dsget/find to get computer information from in the active direrctory of a domain.
The main aim for myself is to condense the information here, and have some links for background information.
If you have the right credentials then the below batch file works very well.
It uses these tools:
- dsquery to query the active directory on your domain controller for the existence and Distinguished Name (or ID/path) of various objects (in this example dsquery computer to check if a computer exists in a domain)
- dsget which can get you various detail information about an object (for instance dsget computer used in this example))
- find to raise the correct errorlevel (and indicate if we indeed found a CN – or Common Name – from a distinguished name)
The ds* tools do not raise any errorlevel, so that’s what find is used for.
Further reading: Read the rest of this entry »