Getting Incomparable Types

Hi Guys,

So I’m trying to write this crazy (at least for me) checking for encryption targetted to Laptops and I’m running into incompatible types. when the system test positive for Sophos.

My understanding is that the boolean goes inside the if statement so when it’s true then it can spot a string and if false it can spit a different string. as long as both were strings.
So if the final result of the software check is a string why am I getting incompatible types.

any assistance is appreciated.

q: if((exists wmi "root\CIMv2\Security\MicrosoftVolumeEncryption" whose (exists select objects "ProtectionStatus, DriveLetter from Win32_EncryptableVolume" whose (integer value of property "ProtectionStatus" of it = 1 AND string value of property "DriveLetter" of it = "C:") of it))) then ("Bitlocker Enabled") else (if((exists structures whose(name of it as lowercase = "portable_battery") of smbios) OR (exists selects "* from Win32_Battery" of wmi) OR (exists selects "* from Win32_PortableBattery" of wmis) OR (exists selects "* from DCIM_Battery" of wmis "root\dcim\sysman"))then (if(exists keys whose (value "DisplayName" of it as string as lowercase starts with "sophos") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of ( registry;native registry ))then((values "DisplayName" of it, values "DisplayVersion" of it) of keys whose (value "DisplayName" of it as string as lowercase contains "sophos") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (registry;native registry))else("System Not Encrypted")) else("Desktop"))
A: Bitlocker Enabled
T: 216.865 ms

You have a check that is a plural registry result and as your other checks are singular registry values, that causes the Incompatible Types error. You would need to make that query evaluate as a singular string to avoid the mismatch.

Q: ((values "DisplayName" of it, values "DisplayVersion" of it) of keys whose (value "DisplayName" of it as string as lowercase contains "sophos") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (registry;native registry))
T: 23.165 ms
I: plural ( registry key value, registry key value )
1 Like

thank you SLB, you are my champion this week.
so follow up dumb question.
since I do need both of the strings, how can I make the entire thing plural then?
Im gonna see if I can find a way of making it singular from plural without having to take out the 2 values

To singularize just the plural section of your expression, something like this perhaps

Q: concatenation "" of ((concatenation ";" of (values "DisplayName" of it as string) & concatenation ";" of (values "DisplayVersion" of it as string)) of keys whose (value "DisplayName" of it as string as lowercase contains "sophos") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (registry;native registry))
A: 
T: 19.222 ms
I: singular string

Not sure how that will come out in your results as I don’t have that registry data but it might do the trick…or give you something to further tweak.

1 Like