Wednesday, February 27, 2013

DCM Script Detect SQL Edition SKUNAME

The script below will check if you have a version of SQLServer insalled and Echo the Edition Skuname and process Architecture.  This is particulary useful if you deem SQL Server on workstations to be a non-compliant trigger.  Now you can validate whether the echoed line is not allowed i.e SQL Server Enterprise

On Error Resume Next
' First try SQL Server 2008/2008 R2:
Set objWMIService = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement10")
If Err.Number <> 0 Then
    ' Next, try SQL Server 2005:
    Set objWMIService = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement")
    If Err.Number <> 0 Then
        ' Next, try SQL Server 2012:
        Set objWMIService = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement11")
    End If
End If

Set colItems = objWMIService.ExecQuery( _
    "select * from SqlServiceAdvancedProperty where SQLServiceType = 1 AND PropertyName = 'SKUNAME'")
For Each objItem in colItems
    Wscript.Echo  objItem.PropertyStrValue

No comments:

Post a Comment