Posts Tagged DSQuery

DSQuery Operating System Service Pack Version

I had a requirement recently to get the service pack versions for all workstations on the domain. I tried a few different options but the easiest option was to use the extremely useful dsquery tool.

Without further ado, this is the command:

dsquery * -scope subtree -attr “cn” “operatingSystem” “operatingSystemServicePack”  -filter “(&(objectclass=computer)(objectcategory=computer)(operatingSystem=Windows XP*))” -limit 100000

The output of this command would be as follows:

cn                 operatingSystem                      operatingSystemServicePack
WRK001    Windows XP Professional     Service Pack 1
WRK002    Windows XP Professional     Service Pack 2
WRK003    Windows XP Professional     Service Pack 3

Where, cn is the workstation name and the others are self explanatory.

Share your handy little tips and tricks!

, , , , ,

No Comments

Get list of machines by OS type from Active Directory

Here is an easy way of getting a list of computers that have a particular OS type from Active Directory using DSQuery.

dsquery * domainroot -filter “(&(objectCategory=computer)(operatingSystem=Windows XP*))”

The command above would give you a list of all computers that have a Windows XP operating system. For Windows Servers, change the command as follows:

dsquery * domainroot -filter “(&(objectCategory=computer)(operatingSystem=Windows Server*))”

The output of the commands above would look something like this:

samid

server1$

server2$

server3$

dsget succeeded

Note the ‘samid’ at the head and ‘dsget succeeded’ at the end and the ‘$’ at the end tail of every server name.

If you are like me, and you would like just get a nice clean output with only server names, you can run this command:

Read the rest of this entry »

, ,

No Comments