WMI "Associators"

(imported topic written by NickFries91)

Hi,

Do you guys support the ASSOCIATORS statement?

http://msdn.microsoft.com/en-us/library/aa384793(VS.85).aspx

Here’s some output when I try to use ASSOCIATORS-

Q:string value of select “ASSOCIATORS OF {Win32_DiskPartition.DeviceID=‘Disk #0, Partition #1’} WHERE ResultClass=Win32_DiskDrive” of wmi

E: The expression could not be evaluated: Windows Error: unknown error 0x80041017

I suspect it is appending a “SELECT” when it sends it off to WMI… Thoughts?

(imported comment written by NickFries91)

NickFries

Hi,

Do you guys support the ASSOCIATORS statement?
http://msdn.microsoft.com/en-us/library/aa384793(VS.85).aspx

Here’s some output when I try to use ASSOCIATORS-
Q:string value of select “ASSOCIATORS OF {Win32_DiskPartition.DeviceID=‘Disk #0, Partition #1’} WHERE ResultClass=Win32_DiskDrive” of wmi
E: The expression could not be evaluated: Windows Error: unknown error 0x80041017

I suspect it is appending a “SELECT” when it sends it off to WMI… Thoughts?

I forgot to add, the error description (from http://forum.bigfix.com/viewtopic.php?id=3025)

80041017 – “Query was not syntactically valid.” – This message will come up if you make a syntax error in your wmi query OR if you try to look up an object/attribute that doesn’t exist

(imported comment written by BenKus)

That is invalid syntax since we only support WMI select syntax… What info are you looking to get?

Ben

(imported comment written by NickFries91)

Hi Ben,

I’m trying to get the model number of the boot drive. The query I posted would have done just that… :\

Regards,

Nick Fries

edit

It’s actually a two part query.

Q:string value of select “DeviceID FROM Win32_DiskPartition WHERE BootPartition = TRUE” of wmi

A: Disk #0, Partition #1

Which feeds into ASSOCIATORS {Win32_DiskPartition.DeviceID=‘Disk #0, Partition #1’} WHERE ResultClass=Win32_DiskDrive

The model comes from “select model from Win32_DiskDrive” however the “DeviceID” column is in a different format.

Win32_DiskPartition DeviceID column format is “Disk #x, Partition #y” (e.g. 'Disk #0, Partition #1)

Win32_DiskDrive DeviceID coumn format is “\.\PHYSICALDRIVEx” (e.g. \.\PHYSICALDRIVE0)

However, associators handles all of the translation which is why I was hoping to use it.

A workaround would be to run query 1 and then pull the disk number then build the PHYSICALDRIVE string then run the second query. I’m not great with relevance since it’s so rare that I work with it so I’m not sure how to do this.

(imported comment written by BenKus)

Well… It isn’t pretty, but I think it works:

q: item 0 of item 0 of ((string value of property “Model” of it as string, escapes of string value of property “DeviceID” of it) of (select objects “Model, DeviceID from Win32_DiskDrive” of wmi), (preceding text of last “%22” of following text of last “.DeviceID=%22” of string value of property “Antecedent” of it, preceding text of last “%22” of following text of last “.DeviceID=%22” of string value of property “Dependent” of it ) of select objects “Antecedent, Dependent from Win32_DiskDriveToDiskPartition” of wmi, string value of select “DeviceID from Win32_DiskPartition where Bootable=True” of wmi) whose ((item 1 of item 0 of it = item 0 of item 1 of it) AND (item 1 of item 1 of it = item 2 of it))
A: ST9500420AS

Basically, I did the same work the “ASSOCIATORS” performs, but I did it using tuples in relevance…

Ben