8.10.1 ProblemYou want to find computers that have a certain OS version, release, or service pack in a domain. 8.10.2 Solution8.10.2.1 Using a graphical user interface
8.10.2.2 Using a command-line interface> dsquery * <DomainDN> -scope subtree -attr "*" -filter "(&(objectclass=[RETURN] computer)(objectcategory=computer)(operatingSystem=Windows Server 2003))" 8.10.2.3 Using VBScript' This code searches for computer objects that have Service Pack 1 installed. ' ------ SCRIPT CONFIGURATION ------ strBase = "<LDAP://" & "<DomainDN>" & ">;" ' ------ END CONFIGURATION --------- strFilter = "(&(objectclass=computer)(objectcategory=computer)" & _ "(operatingSystemServicePack=Service Pack 1));" strAttrs = "cn,operatingSystem,operatingSystemVersion," & _ " operatingSystemServicePack;" strScope = "subtree" set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) objRS.MoveFirst while Not objRS.EOF Wscript.Echo objRS.Fields(0).Value Wscript.Echo objRS.Fields(1).Value Wscript.Echo objRS.Fields(2).Value Wscript.Echo objRS.Fields(3).Value Wscript.Echo objRS.Fields(4).Value WScript.Echo objRS.MoveNext wend 8.10.3 DiscussionWhen a computer joins an Active Directory domain, the operating system attributes are updated for the computer object. There are four of these attributes, which can be used in queries to find computers that match certain OS-specific criteria, like service pack level. These attributes include the following:
|