DS Query Commands
DS Query Commands
23. How to find RID master role holder for existing domain ?
dsquery server -hasfsmo RID
24. How to find Schema master role holder in a Forest ?
dsquery server -forest -hasfsmo Schema
25. How to find Domain Naming Master in a Forest ?
dsquery server -forest -hasfsmo Name
26. How to find if the Domain Controller is a Global Catalog (GC) or not ?
dsquery server -name test1 | dsget server -isgc
27. How to find subnet with associated site.
dsquery subnet -name 10.222.88.0/25 | dsget subnet
28. How to find SID of a user?
dsquery user -samid <bbiswas> | dsget user -sid
dsquery * -filter (samaccountname=Biswajit) attr sid
29. How to find sIDHisotry of a user?
Dsquery * -filter (samaccoutname=Bbiswas) attr siDhistory
30. How to find enabled computer accounts in an OU?
dsquery computer OU=Test,DC=contoso,DC=com -limit 5000 | dsget computer -dn -disabled |
find /i " no"
31. How to count enabled computer accounts in an OU?
dsquery computer OU=Test,DC=contoso,DC=com -limit 5000 | dsget computer -dn -disabled |
find /c /i " no"
32. How to find all members for a OU.
dsquery user ou=targetOU,dc=domain,dc=com
("bshwjt" is the user and test is the "PSO" also see the below snap)
52.The output of the dsquery command can be used as input for the dsget command by using a
pipe ( | ). In this example, the SAM account name and the security ID (SID) of each user is
displayed.
dsquery user | dsget user -samid -sid -limit 0 >> c:\Allusers-samid-sid.txt
53. How to find RODC
60.Extract the all groups from an OU with Group Scope & Group Type. Find the
below snap for your reference.
C:\>dsquery group "ou=test,dc=gs,dc=com" -limit 0 | dsget group -samid -scope -secgrp
61.The following example displays a list of users of the Organigation Unit "Techie Sol",
can then be forwarded to dsget that can provide detailed information about objects.
In the example, the requested user list is headed by the pipe symbol after dsget that
-outputs then the sAMAccountName for all users and email address.
If you wanted to carry out modifications to the information returned by DSQuery user list,
we could send the result to dsmod, which for us is making changes to all users.
In following Image shows the changes in the command ensures that all users of DSQuery
-user list must change their passwords in next logon.
Another way to get the user attributes from an OU. Find the below snap & dsquery for that.
C:\>dsquery * "ou=test,DC=contoso,DC=com" -filter "(&(objectcategory=person)
(objectclass=user))" -limit 0
-attr samaccountname description department title
62.retrieve the DN of all users in the domain that are not direct members of a
specified group
>>dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!
(memberOf=Groupname,ou=West,
dc=Contoso,dc=com))) -limit 0 > NotInGroup.txt
63. How to open DSQUERY GUI Window
rundll32 dsquery,OpenQueryWindow
DNS application partition
64. How to find the DNS servers from DomainDNSZones & ForestDNSzones
67. Find the DNS servers from all the DNS partitions.