WMI namespace question

(imported topic written by dmoore21)

Can I specify a namespace when using the WMI inspectors? It would appear that the only WMI queries that I can utilize are those found in the cimv2 and rsop namespaces… But I would really like to be able to check the Root\Microsoft\SqlServer namespaces too…

(imported comment written by NoahSalzman)

Yep. Should work, if you get the root name and classes right.

q:

selects
"* from SqlServiceAdvancedProperty"
of

wmi
"root\Microsoft\SqlServer\ComputerManagement10"

A:
IsReadOnly=True

A:
PropertyIndex=0

A:
PropertyName=SQLSTATES

A:
PropertyNumValue=2099205

A:
PropertyStrValue

A:
PropertyValueType=2

A:
ServiceName=MSSQLSERVER

A:
SqlServiceType=1

(imported comment written by dmoore21)

Ok, follow on question…

Microsoft has the irritating habit of incrementing the numerical value of the path with each new SQL Server release… is there a way that I can specify a wildcard in the WMI path? Something like this:

(string values of properties “PropertyStrValue” of (select objects “* from SqlServiceAdvancedProperty WHERE PropertyName = ‘Version’” of wmi “root\Microsoft\SqlServer\ComputerManagement*”))

(imported comment written by NoahSalzman)

I’m not a WMI expert, but I do not think you can do that.

(imported comment written by dmoore21)

I wound up doing this:

if (exists (wmi “root\Microsoft\SqlServer\ComputerManagement”)) then (string values of properties “PropertyStrValue” of (select objects “* from SqlServiceAdvancedProperty WHERE PropertyName = ‘Version’” of wmi “root\Microsoft\SqlServer\ComputerManagement”)) else if (exists (wmi “root\Microsoft\SqlServer\ComputerManagement10”)) then (string values of properties “PropertyStrValue” of (select objects “* from SqlServiceAdvancedProperty WHERE PropertyName = ‘Version’” of wmi “root\Microsoft\SqlServer\ComputerManagement10”)) else if (exists (wmi “root\Microsoft\SqlServer\ComputerManagement11”)) then (string values of properties “PropertyStrValue” of (select objects “* from SqlServiceAdvancedProperty WHERE PropertyName = ‘Version’” of wmi “root\Microsoft\SqlServer\ComputerManagement11”)) else nothing

But now my question is this: Since I’m using this as an analysis statement, how can I modify the output to display something like ‘SQL Server 2008 Express SP1’ instead of ‘10.1.2531.0’…

EDIT

Or, is there a way that the relevance can be modified so that I can filter out all versions that start with a 9?

(imported comment written by jgstew)

Have you taken a look at this:

http://bigfix.me/analysis/details/2994632

Or “Microsoft SQL Server and Client Tools Version Detection” analysis in the “BES Inventory and License” site?

Realize it’s been many years since this topic, but as this is the one I kept coming across when I was searching on this, thought I’d post my solution. It was hard-won.

Listing NameSpaces:

q: selects "Name from __NAMESPACE" of wmis "root"
A: Name=subscription
A: Name=DEFAULT
A: Name=CIMV2
A: Name=msdtc
A: Name=Cli
A: Name=SECURITY
A: Name=SecurityCenter2
A: Name=RSOP
A: Name=SDDC
A: Name=PEH
A: Name=StandardCimv2
A: Name=WMI
A: Name=AccessLogging
A: Name=directory
A: Name=Policy
A: Name=InventoryLogging
A: Name=Interop
A: Name=Hardware
A: Name=ServiceModel
A: Name=Microsoft
A: Name=Appv
T: 492.048 ms
I: plural wmi select

Which NameSpaces reside beneath root/Microsoft/SqlServer:

q: string values of properties "Name" of select objects "Name from __NAMESPACE" of wmis "root/Microsoft/SqlServer"
A: ServerEvents
A: ComputerManagement13
T: 486.220 ms
I: plural string

Which of those is a ComputerManagement namespace:

q: string values of properties "Name" of select objects "Name from __NAMESPACE WHERE Name LIKE 'ComputerManagement%25'" of wmis "root/Microsoft/SqlServer"
A: ComputerManagement13
T: 483.203 ms
I: plural string

Build a query for SQL properties, using a namespace generated by concatenating the “ComputerManagementXX” namespace to /root/Microsoft/SqlServer:

q: selects "* from SqlServiceAdvancedProperty" of wmis (("root/Microsoft/SqlServer/" & it) of string values of properties "Name" of select objects "Name from __NAMESPACE WHERE Name LIKE 'ComputerManagement%25'" of wmis "root/Microsoft/SqlServer")
A: IsReadOnly=True
A: PropertyIndex=0
A: PropertyName=SQLSTATES
A: PropertyNumValue=2053
A: PropertyStrValue
A: PropertyValueType=2
A: ServiceName=MSSQLSERVER
A: SqlServiceType=1
A: IsReadOnly=True
A: PropertyIndex=1
A: PropertyName=VERSION
A: PropertyNumValue
A: PropertyStrValue=13.2.5026.0
A: PropertyValueType=0
A: ServiceName=MSSQLSERVER
A: SqlServiceType=1
A: IsReadOnly=True
A: PropertyIndex=2
A: PropertyName=SPLEVEL
A: PropertyNumValue=2
A: PropertyStrValue
A: PropertyValueType=2
A: ServiceName=MSSQLSERVER
...and many more
2 Likes

Thanks Jason!!
This is really helpful.