Here are some useful commands and scripts for administering Active Directory. For more information please see Active Directory Domain Services Command Reference. Reference : userAccountControl
Identify OCS enabled users in Active Directory
Query Password Last Set (pwdlastset) value
Note: Time can be converted using the w32tm /ntte command.
Search Password Never Expires Settings
User accounts with no pwd required
Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=32))"
Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))"
User accounts with “Do not require kerberos preauthentication” enabled
List all Roaming Profile users in Active Directory
Generate SIDHistory Report
Generate SID (ObjectSID) Report
Identify all Security Groups
Identify all Built-In Security Groups
Identify all Universal Security Groups
Identify all Global Security Groups
Move Computer Objects Based on OS Version
Move Windows 7 Computers
Move Windows XP Computers
List all Sites in Active Directory
Get Site Name from Subnet IP Address in Active Directory (For example, Site Name for Subnet 192.168.2.0/24)
Dsquery * “CN=Configuration,DC=Santhosh,DC=lab” -attr Whencreated -Scope Base
Find Trusts from specified Domain
Dsquery * "CN=System,DC=Santhosh,DC=lab" -filter "(objectClass=trustedDomain)" -attr TrustPartner FlatName
Find Servers in Active Directory with descriptions
Dsquery * DC=Santhosh,DC=lab -filter "(&(objectCategory=Computer) (operatingSystem=*server*))" -limit 0 -attr cn description
Dsquery * CN=Schema,CN=Configuration,DC=Santhosg,DC=lab-filter "(&(objectCategory=attributeSchema)(!systemFlags:1.2.840.113556.1.4.803:=1))" -limit 0
Dsquery *"CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=Santhosh,DC=lab"-attr GarbageCollPeriod TombstoneLifetime
Dsquery * "CN=Policies,CN=System,DC=Santhosh,DC=lab"-filter (objectCategory=groupPolicyContainer) -attr Name DisplayName
Dsquery * "CN=Policies,CN=System,DC=Santhosh,DC=lab"-filter "(objectCategory=groupPolicyContainer)"-attr displayName cn whenCreated gPCFileSysPath
Dsquery * "CN=System,DC=Santhosh,DC=lab" -filter "(objectClass=trustedDomain)"-attr TrustPartner FlatName
Dsquery * "CN=Subnets,CN=Sites,CN=Configuration,DC=Santhosh,DC=lab"-attr CN SiteObject Description Location
Dsquery * "CN=Sites,CN=Configuration,DC=Santhosh,DC=lab"-attr CN Cost Description ReplInterval SiteList -filter (objectClass=siteLink)
Congrats on getting featured on the front page of TechNet! Great article!
Thanks Ed!
Nice one
Very helpfull blog
Thanks Darshana!
Great article as usual
Thanks Abdelhamid.
Very useful and Great article.
Thanks Santhosh
Thanks Partis. Thanks for adding those additional commands.
Thanks Santhosh, but again display problem with long commands. I had this problem and Bruno Lewin - MSFT solved. Ed know about this problem. I mean this article:
social.technet.microsoft.com/.../5126.aspx