Querying Specific Operating System Types in Active Directory

by [Published on 6 July 2016 / Last Updated on 6 July 2016]

Tip shows how to use DSQuery to find systems running Windows 7 and Windows 8\8.1.

In case you need to get a list of computer accounts that belong to a specific Operating System family, you can use DSQuery commands as listed in below commands:

Querying Windows 8 and Windows 8.1 Computers:

  • dsquery * -filter "(&(&(sAMAccountType=805306369)(objectCategory=computer)(operatingSystemVersion=6*)(operatingSystem=Windows 8*)))" -limit 0 -attr name operatingsystem

Querying Windows 7 Computers:

  • Dsquery * -filter "(&(&(sAMAccountType=805306369)(objectCategory=computer)(operatingSystemVersion=6*)(operatingSystem=Windows 7*)))" -limit 0 -attr name operatingsystem

About Nirmal Sharma

Nirmal Sharma is a MCSEx3, MCITP and Microsoft MVP in Directory Services. He specializes in directory services, Microsoft Azure, Failover clusters, Hyper-V, and System Center products and has been involved with Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to Health Packs for ADHealthProf.ITDynamicPacks.Net solutions. Nirmal can be reached at nirmal_sharma@mvps.org.

See Also


The Author — Nirmal Sharma

Nirmal Sharma avatar

Nirmal Sharma is a MCSEx3, MCITP, and was awarded Microsoft MVP in Directory Services. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles for various online communities. Nirmal can also be found contributing to PowerShell based Dynamic Packs for ADHealthProf.ITDynamicPacks.Net solutions.