We help IT Professionals succeed at work.

DSQuery:  Querying Operating System Types within AD

Hi Experts,

     Is there a DSQUERY that will query my Active Directory environment so I can get a list of what operating systems are being used out there, then pipe it out to a > C:\OperatingSystem-Report.csv ?
Comment
Watch Question

Top Expert 2013
Commented:
Does it have to be dsquery?   Adfind is a great tool for this kind of thing too

 http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -default  -f "objectcategory=computer" name operatingsystem operatingsystemversion -nodn -csv >  c:\operatingSystemReport.csv

Thanks

Mike
Chris DentPowerShell Developer
Top Expert 2010
Commented:

The formatting will certainly be far nicer with Mike's suggestion. If it must be dsquery then:

dsquery * -Filter "(&(objectClass=computer)(operatingSystem=*))" -Attr name operatingSystem

Or just operatingSystem for the Attr.

PowerShell alternative, just because :)

Get-QADComputer -OperatingSystem * | Select-Object Name, OperatingSystem | Export-CSV SomeFile.csv

Chris
Sr. Analyst - System Administrator
Commented:
HI Check this queries

Hope this will be useful for you

Query All OS:

dsquery * -Filter "(&(objectClass=computer)(operatingSystem=*))" -limit 0 -Attr name operatingSystem

Query Windows 7:

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



Query Windows XP:

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



Query Windows 2003:

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


Query Windows 2008:

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

Good Luck

Cheers,
Prem

Author

Commented:
You guys are great!  Thank you all very much!