IF THEN ELSE - WMI value Analysis

I am trying to get the following Analysis to Output “N/A” but on systems (like a virtual) that it doesn’t exist, it returns “Error: Singular expression refers to nonexistent object.”

if exists (tuple string item 0 of string value of selects “ManufacturerVersion from Win32_Tpm” of wmis “root\CIMV2\Security\MicrosoftTpm”) then (tuple string item 0 of string value of selects “ManufacturerVersion from Win32_Tpm” of wmis “root\CIMV2\Security\MicrosoftTpm”) as string else “N/A”

Plurals are your friend here. The “if” block gives the singular error if “string value of” doesn’t exist. Try

if exists (tuple string items 0 of string values of selects “ManufacturerVersion from Win32_Tpm” of wmis “root\CIMV2\Security\MicrosoftTpm”) then (tuple string items 0 of string values of selects “ManufacturerVersion from Win32_Tpm” of wmis “root\CIMV2\Security\MicrosoftTpm”) as string else “N/A”

1 Like

Thank you Jason, that did the trick!