Relevancy with multiple returns

I have a relevancy that looks at registry key names. It returns True or False for each key name. The problem is that if it returns True for one Line, and False for another the fixlet still shows up as not relevant. I want it to show up as relevant if all the returns are True, or even just one of the returns is true.

(Name of it as lowercase contains “reg_sz”) of (keys of it) of key “HKLM\System\SAC-ISC” of registry

The Registry I have is
HKLM\System\SAC-ISC\Packages
HKLM\System\SAC-ISC\Packages" /v AppEdition /t REG_SZ

So the Relevancy shows False for the first key, and True for the 2nd key. But because there is one false the relevancy shows up as not Relevant, but for a case like this where there is at least one True I want it to be Relevant.

Thanks

Can you provide an example path?

You should test this progressively as you go in the Fixlet Debugger to make sure it returns what you expect:

names of keys of keys "HKLM\System\SAC-ISC" of registries

Then:

values "AppEdition" of keys of keys "HKLM\System\SAC-ISC" of registries

Then to make it true/false:

exists values "AppEdition" of keys of keys "HKLM\System\SAC-ISC" of registries

registry

I’ve attached an image of the registry keys.

So with that relevance it comes back as False for the key name “Packages”, and True for the key named “Packages” /v AppEdition /t REG_SZ"

So it’s the correct output, but I need a way that if any of the outputs comes back as True the relevancy will be equated as True, if the output is false all results then it will be false if that’s possible

Try:

q: exists keys ("packages";"packages%22 /v AppEdition /t REG_SZ") of keys "HKLM\System\SAC-ISC" of native registry
A: False

This should return true only if one or more of the keys is present. (note the %22 = " )
Side note - that second key looks a lot like someone along the way missed a doubleqoute on a Reg Set command.

This variation would test for “both keys are present”

q: (exists key "packages" of it and exists key "packages%22 /v AppEdition /t REG_SZ" of it) of keys "HKLM\System\SAC-ISC" of native registry

Ya that was our issue it was a missed reg add, so we are trying to make a fixlet that will clean up those keys, there are about 7-9 different variants, so we want the scripts be relevant if the key name contains Reg_SZ.

Some people have a couple of the keys, others have a more severe set of keys. Pretty much if it just contains Packages key we want it to be False and not run, but if it contains “Reg_SZ” in the key name then we want it to result in a True relevance and allow the fixlet to be run to fix the registry keys.

Here is a screen capture of someone with more keys.
registry keys

1 Like

Thanks, that screenshot helps me understand exactly what you need.

This is what you want:

exists keys whose(name of it contains "REG_SZ") of keys "HKLM\System\SAC-ISC" of registries

I was just thrown by looking for REG_SZ in the name of the KEY like that. I assumed something else entirely.

2 Likes

That is awesome, totally works. Thanks so much for the help guys

For the cleanup, you might find this relevance useful in your action script, in conjunction with a bat file.

("reg delete %22HKLM\System\SAC-ISC\" & it & "%22 /f") of names of keys whose(name of it contains "Packages" AND name of it contains "REG_SZ") of keys "HKLM\System\SAC-ISC" of registries

Although I am not sure if that embedded double-quote in the middle of the key path needs to be escaped or not.

UPDATE:
looks like singlequotes help with the escaping…

("reg delete 'HKLM\System\SAC-ISC\" & it & "' /f") of names of keys whose(name of it contains "Packages" AND name of it contains "REG_SZ") of keys "HKLM\System\SAC-ISC" of registries

We actually did the removal using a powershell command

Remove-Item -path “HKLM:\System\SAC0ISC*” -exclude ‘Packages’

we knew we only wanted to keep the one Registry key and remove all other keys under this branch of the registry, so it was very straight forward to code it this way and just trigger the powershell code.

1 Like