(type of select “FreeSpace from Win32_LogicalDisk where DriveType=2 and DeviceID=‘A:’” of wmi) as integer = 8
(type of select “FreeSpace from Win32_LogicalDisk where DriveType=5 and DeviceID=‘D:’” of wmi) as integer = 8
Obviously it’s really easy to spot the limitation - it is hardcoded to a specific drive letter!
So here is my suggestion - it would be great if we could have a WMI iterator that would let you evaluate a collection returned by WMI and possibly even return an array of values. As it is you have to ensure that the WMI query returns a singular object.
For example
imaginary code start
################
Q: ((select “DeviceID from Win32_LogicalDisk where DriveType=5” of wmi) as array of string) as string
A: D:, F: (as opposed to the “Singular expression referes to non-unique object.” currently being returned)
and
Q: collection of ((type of select “FreeSpace from Win32_LogicalDisk where DriveType=5” of wmi) as array of integer) = 8
A: True if at least one of the values in the collection = 8, False if none
################
imaginary code end
What do you think, would this be of any value to anyone? Or would it just mean a huge headache for BigFix developers because it introduces new primitive object?
Regards,
Rad
PS: If you are gonna use the two expressions to check for floopy and CD don’t forget to set the “Evaluate every” value to something more than every report as they are quite costly in CPU terms.
Assuming Windows OS since you mentioned Windows Management Interface.
color=red
q:[/color] names
color=blue
of[/color] drives
color=blue
whose[/color] ((type
color=blue
of it [/color]= “DRIVE_REMOVABLE”
color=blue
OR[/color] type
color=blue
of it[/color] = “DRIVE_CDROM”) and (
color=blue
exists[/color] file system type
color=blue
of it[/color]))
color=red
A:[/color] A:
color=red
A:[/color] D:
color=red
A:[/color] E:
color=red
T:[/color] 2851.361 ms
color=red
I:[/color] plural string
I had a floppy, a CD and a jump drive inserted. It is slow, because it is actually spinning up the drives. With no removable drives or CDs inserted I get:
color=red
q:[/color] names
color=blue
of[/color] drives
color=blue
whose[/color] ((type
color=blue
of it [/color]= “DRIVE_REMOVABLE”
color=blue
OR[/color] type
color=blue
of it[/color] = “DRIVE_CDROM”) and (
color=blue
exists[/color] file system type
color=blue
of it[/color]))
color=red
T:[/color] 1099.433 ms
color=red
I:[/color] plural string
Not sure of slick way to exclude the jump drive from showing up.
You can accomplish everything you want in the relevance language today. Whenever you see the error “Singular expression referes to non-unique object.”, it means you need to add an “s” somewhere to make a plural value. In this case, use “selects”.
This answers your questions about concatenating the drives and searching the returned types:
q: concatenation ", " of (string values of selects “DeviceID from Win32_LogicalDisk” of wmi)
A: C:, D:, K:, M:, N:, O:, P:, Q:
q: exists (types of selects “DeviceID from Win32_LogicalDisk” of wmi) whose (it = 8)
A: True
But for this specific example, please note (as brolly33 showed nicely) that we have a full array of disk inspectors that are far superior to the wmi implementation in many ways.