|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Script to determine OS version domain wide
I'm looking for a script to report back on the OS version for all
workstations on a single domain. Ultimately, I'm trying to determine which XP workstations have not been patched to SP 1. Thanks! Chris "Chris" <Ch***@discussions.microsoft.com> wrote in message There's lot's of good examples in the TechNet Script Center:news:31A24534-D996-44DB-BC32-3BC4E6A6A013@microsoft.com... > I'm looking for a script to report back on the OS version for all > workstations on a single domain. Ultimately, I'm trying to determine which > XP > workstations have not been patched to SP 1. Thanks! Chris http://www.microsoft.com/technet/scriptcenter/scripts/misc/searchad/mssevb11.mspx There's several ways to do this, one method would be to get the list of computers from AD, then contact each machine that's online and ask it for it's OS & service pack level. Here is another method that asks AD for the OS of all computer accounts (even if they are offline/retired): On Error Resume Next Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = ("ADsDSOObject") objConnection.Open "Active Directory Provider" objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT Name, operatingSystemVersion, operatingSystemServicePack " _ & "FROM 'LDAP://DC=mydomain,DC=com' " _ & "WHERE objectClass='computer' AND " _ & "operatingSystemVersion='5.1 (2600)'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF Wscript.Echo objRecordSet.Fields("Name").Value & "=" & _ objRecordSet.Fields("operatingSystemVersion").Value & " " & _ objRecordSet.Fields("operatingSystemServicePack").Value objRecordSet.MoveNext Loop Thanks for the reply Marty. I forgot to mention that we are a non-AD
environment. Show quote "Marty List" wrote: > > "Chris" <Ch***@discussions.microsoft.com> wrote in message > news:31A24534-D996-44DB-BC32-3BC4E6A6A013@microsoft.com... > > I'm looking for a script to report back on the OS version for all > > workstations on a single domain. Ultimately, I'm trying to determine which > > XP > > workstations have not been patched to SP 1. Thanks! Chris > > > There's lot's of good examples in the TechNet Script Center: > http://www.microsoft.com/technet/scriptcenter/scripts/misc/searchad/mssevb11.mspx > > There's several ways to do this, one method would be to get the list of > computers from AD, then contact each machine that's online and ask it for > it's OS & service pack level. Here is another method that asks AD for the > OS of all computer accounts (even if they are offline/retired): > > > On Error Resume Next > > Const ADS_SCOPE_SUBTREE = 2 > > Set objConnection = CreateObject("ADODB.Connection") > Set objCommand = CreateObject("ADODB.Command") > objConnection.Provider = ("ADsDSOObject") > objConnection.Open "Active Directory Provider" > objCommand.ActiveConnection = objConnection > objCommand.Properties("Page Size") = 1000 > objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE > objCommand.CommandText = _ > "SELECT Name, operatingSystemVersion, operatingSystemServicePack " _ > & "FROM 'LDAP://DC=mydomain,DC=com' " _ > & "WHERE objectClass='computer' AND " _ > & "operatingSystemVersion='5.1 (2600)'" > Set objRecordSet = objCommand.Execute > objRecordSet.MoveFirst > > Do Until objRecordSet.EOF > Wscript.Echo objRecordSet.Fields("Name").Value & "=" & _ > objRecordSet.Fields("operatingSystemVersion").Value & " " & _ > objRecordSet.Fields("operatingSystemServicePack").Value > objRecordSet.MoveNext > Loop > > > > "Chris" <Ch***@discussions.microsoft.com> wrote in message Well that would definitely be worth mentioning in the year 2005 :)news:D046CD6E-B5CD-45C0-9043-208E01043332@microsoft.com... > Thanks for the reply Marty. I forgot to mention that we are a non-AD > environment. This is a combination of these two samples, and will work in an NT4 domain: http://www.microsoft.com/technet/scriptcenter/scripts/ds/local/users/lousvb08.mspx http://www.microsoft.com/technet/scriptcenter/scripts/os/version/ostveb02.mspx This will be a lot slower since it needs to contact each machine (or time out if the machine is not available): Option Explicit On Error Resume Next Dim objDomain, objComputer, colOS, objOS, objWMI Dim strComputer, strOperatingSystem Set objDomain = GetObject("WinNT://MYDOMAIN,domain") objDomain.Filter = Array("Computer") For Each objComputer In objDomain Set objWMI = Nothing Set colOS = Nothing strOperatingSystem = "Unknown" strComputer = objComputer.Name Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\cimv2") Set colOS = objWMI.ExecQuery("Select * from Win32_OperatingSystem") For Each objOS in colOS strOperatingSystem = objOS.Version & " Service Pack " & _ objOS.ServicePackMajorVersion Next Wscript.Echo objComputer.Name & "=" & strOperatingSystem Next Thank you very much! BTW, we are moving to AD (finally) in early 2006 :-)
Show quote "Marty List" wrote: > > "Chris" <Ch***@discussions.microsoft.com> wrote in message > news:D046CD6E-B5CD-45C0-9043-208E01043332@microsoft.com... > > Thanks for the reply Marty. I forgot to mention that we are a non-AD > > environment. > > > Well that would definitely be worth mentioning in the year 2005 :) > > This is a combination of these two samples, and will work in an NT4 domain: > http://www.microsoft.com/technet/scriptcenter/scripts/ds/local/users/lousvb08.mspx > http://www.microsoft.com/technet/scriptcenter/scripts/os/version/ostveb02.mspx > > This will be a lot slower since it needs to contact each machine (or time > out if the machine is not available): > > > Option Explicit > On Error Resume Next > > Dim objDomain, objComputer, colOS, objOS, objWMI > Dim strComputer, strOperatingSystem > > Set objDomain = GetObject("WinNT://MYDOMAIN,domain") > objDomain.Filter = Array("Computer") > > For Each objComputer In objDomain > Set objWMI = Nothing > Set colOS = Nothing > strOperatingSystem = "Unknown" > strComputer = objComputer.Name > Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ > strComputer & "\root\cimv2") > Set colOS = objWMI.ExecQuery("Select * from Win32_OperatingSystem") > For Each objOS in colOS > strOperatingSystem = objOS.Version & " Service Pack " & _ > objOS.ServicePackMajorVersion > Next > Wscript.Echo objComputer.Name & "=" & strOperatingSystem > Next > > > > > |
|||||||||||||||||||||||