Home » Windows

Useful Commands to Query in Active Directory

6 February 2011 No Comment

Useful Command to Query in Active DirectoryActive Directory is a directory service created by Microsoft. It stores all information and settings in a database.

There are many things you can do using the graphical user interface to query in Active Directory. But if you like the elegance of a script or the pure speed of a command line, these commands are the way to go.

If you don’t think you need to use the command line since you’re in Windows, think about. System Administrators should get into the habit of using the command line as a quick and fast way to look up information or write a script.

Q1. How to find all GCs in a forest?

dsquery server -forest -isgc

Q2. How to find the owner of an individual FSMO role?

dsquery server -hasfsmo <Role>

where <Role> can be schema, name, infr, pdc, or rid

Q3. How to list all subnets?

dsquery subnet

Q4. How to list all DCs in a domain?

dsquery * cn=configuration,<ForestRootDN> -filter (objectclass=ntdsdsa)

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.