Detect Windows Standard vs Enterprise remotely
Hi All,
I am trying to figure out a way to find the version of OS remotely, either with some Registry search or SNMP get. I would like to know is a group of servers are running Standard or Enterprise edition. Anyone know of a way?
Thanks,
Roberto
April 5th, 2011 10:28am
You can use this PowerShell script:
http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html
Just remove the user profile section.
Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX
Blogs - http://blogs.sivarajan.com/
Articles - http://www.sivarajan.com/publications.html
Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
This posting is provided AS IS with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2011 11:58am
Hello,
In case that you don't yet use powershell yet you can just use the WmiObject win32_operatingsystem.
BR.RipPle
April 5th, 2011 5:34pm
You should also be able to query AD for this, eliminating the need to connect to each computer remotely. The operatingSystem attribute of computer objects will have values like "Windows Server 2008 R2 Standard". You could query AD for all computers where
the operatingSystem attribute has the string "server" and either "standard" or "enterprise".
I have an example VBScript program that retrieves all servers linked here:
http://www.rlmueller.net/Enumerate%20Servers.htm
The LDAP syntax filter used in this program is:
(&(objectCategory=computer)(operatingSystem=*server*))
This could be revised, perhaps to:
(&(objectCategory=computer)(operatingSystem=*server*)(operatingSystem="standard"))
or even (since only computer objects have the operatingSystem attribute):
(operatingSystem=Windows Server 2008 R2 Standard)
The strings are not case sensitive. You could add the operatingSystem attribute to the comma delimited list of attributes to retrieve, then in the loop where the resulting recordset is enumerated, you can output the value of operatingSystem. The result could
be as follows, to find all computers with a "standard" "server" OS:
Option Explicit
Dim objRootDSE, strDNSDomain, adoConnection, adoCommand, strQuery
Dim adoRecordset, strComputerDN, strBase, strFilter, strAttributes
Dim strOS
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use ADO to search Active Directory.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Filter on computer objects with standard server operating system.
strFilter = "(&(objectCategory=computer)(operatingSystem=*server*)(operatingSystem=*standard*))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,operatingSystem"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
' Enumerate computer objects with standard server operating systems.
Do Until adoRecordset.EOF
strComputerDN = adoRecordset.Fields("distinguishedName").Value
strOS = adoRecordset.Fields("operatingSystem").Value
Wscript.Echo strComputerDN & " (" & strOS & ")"
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
adoConnection.Close
A very similar PowerShell script can be coded, using the same LDAP syntax filters.
Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2011 9:06pm
Here is another Script. You can read more info in the follwoing thread:
http://social.technet.microsoft.com/Forums/en-US/winserverDS/thread/4256c1e7-2491-4513-ab6f-70dee63a8d24/#cb77041f-6778-4dfc-9cc9-bf59a9d202a3
Option Explicit
Dim oFSO, sFile, oFile, strComputer, objWMIService, colOSes, obJOS
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = "C:\input.txt"
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
strComputer = oFile.ReadLine
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
Wscript.Echo "Computer Name: " & objOS.CSName
Wscript.Echo "Caption: " & objOS.Caption 'Name
Wscript.Echo "Version: " & objOS.Version 'Version & build
Wscript.Echo "Build Number: " & objOS.BuildNumber 'Build
Wscript.Echo "Build Type: " & objOS.BuildType
Wscript.Echo "OS Type: " & objOS.OSType
Wscript.Echo "Other Type Description: " & objOS.OtherTypeDescription
Next
Loop
oFile.Close
Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX
Blogs - http://blogs.sivarajan.com/
Articles - http://www.sivarajan.com/publications.html
Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
This posting is provided AS IS with no warranties, and confers no rights.
April 6th, 2011 3:19pm