Weird Error Message

(imported topic written by jaz23)

I’m trying to create an audit, and getting a very weird error - “The left operand of ‘>=’ must be singular”

the statement I am trying to figure out = if (selects “size from win32_DiskDrive” of wmi >= “42949672960”) then “Audit passed” else “Audit failed”

Does anyone have any suggestions??

thx

jaz

(imported comment written by jessewk)

Hi Jaz,

The right and left side of a boolean operator must both evalute to singular boolean values, either True or False. Your conditional check returns a plural boolean result on the left hand side. It’s plural because you used ‘selects’ instead of ‘select’. Even if only one result is returned, the result type is still going to be a plural. Note that your error is getting triggered before the actual wmi call is made, when the relevance passes through an initial sytanx check. During the syntax check there is no way to know that there will only ever be one result on the left hand side of the >= operator, so the check fails. Also, you want both sides of boolean operator ( >= ) to be integers instead of strings and you want to extract the value portion of the select.

There are a number of ways to rewrite your statement.

The easiest:

if (string value of select “size from win32_DiskDrive” of wmi as integer >= 42949672960) then “Audit passed” else “Audit failed”

The above assumes that the select will only ever return one result. If the number of results is ever 0 or > 1 the expression will error. That’s probably not an accurate assumption, so here’s a slight tweak:

if (exists string value whose (it as integer >= 42949672960) of selects “size from win32_DiskDrive” of wmi) then “Audit passed” else “Audit failed”

The above will return passed if there is at least one drive with size > 42949672960.

If you need all drives to pass the check, you could use something like this:

if (conjunction of (it as integer >= 42949672960) of string values of selects “size from win32_DiskDrive” of wmi) then “Audit passed” else “Audit failed”

Interestingly, conjunction of nothing will return true, so you actually need to add one more check:

if (exists string value of selects “size from win32_DiskDrive” of wmi AND conjunction of (it as integer >= 42949672960) of string values of selects “size from win32_DiskDrive” of wmi) then “Audit passed” else “Audit failed”

With all that said, there is a much eaiser and more efficent way to get at this information by avoiding WMI and using our native inspectors. Here is the ‘at least one drive passes’ version:

if (exists drive whose (type of it = “DRIVE_FIXED” AND total space of it > 42949672960)) then “Audit passed” else “Audit failed”

Add the version where all fixed drives are required to pass the test:

if (exists drive whose (type of it = “DRIVE_FIXED”) AND conjunction of (type of it = “DRIVE_FIXED” AND total space of it > 42949672960) of drives) then “Audit passed” else “Audit failed”