I need your help, i was doing research but i cant find nothing that can help me.
I have this query :
exists value whose (name of it is "Enabled") of key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\server" of native registry
And in a few servers i have the response “Singular expression refers to non-existent object”. Yes, i know that the key doesnt exist. but I need that query to give a boolean value, true if it exists or false if it does not exist (it is for some compliance controls) and I am not able to get false if it does not exist.
right, you can’t check the value if the key doesn’t exist. Try checking if the key exists and a value of it:
exists key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\server" whose (exists value "Enabled" of it) of native registry
You can check for the key itself and then the value of it, something like this:
exists key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\server" whose (exists value "Enabled" whose (it as string = "1") of it) of native registry
Another approach that I learnt from everyones Bigfix buddy Mr @jgstew is to pluralize the inspection and this will both simplify the relevance as well as deal with non-existent data, eg
Q: exists value "Enabled" of key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\server" of native registry
E: Singular expression refers to nonexistent object.
Q: exists values "Enabled" of keys "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\server" of native registry
A: False
T: 0.082 ms
I: singular boolean