Create a report that Returns True/False Flags

(imported topic written by HGA8191)

Hi I need to create a report that checks for the existence of several Registry keys and then returns True or False…

Example.

Return True if the following Key exists:

HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E

Else False.

Also return the value of REG_SZ “ProductName” within that key.

Any help will be highly appreciated.

Thanks

HGA81

(imported comment written by JasonO91)

Hey HGA81,

I don’t think I understand how you want the report to look.

Here’s the relevance to accomplish what you want, but the report will only show a value or False.

if (exist key “HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E” of registry) then

value “ProductName” of key “HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E” of registry as string else

“False”

(imported comment written by brolly3391)

Hello HGA81,

This should be easy enough. It looks like you are checking for certain MSI products that are installed. You should be able to use a construct like this:

exists key “HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E” of registry

This will return true if the key exists and false if it does not exist.

If you have a set of keys and want to check if all of them are present you can combine the statements with AND. If you are interested if any one of them are present then combine with OR.

As far as the value “ProductName” we could do that as an if/then/else

if (exists key “HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E” whose (exists value “ProductName” of it) of registry) then (value “ProductName” of key “HKEY_CLASSES_ROOT\Installer\Products\904010001E872D116BF00006799C897E” of registry as string) else (“not installed”)

Give me a little bit more detail on what your report does if you need some further help.

Cheers,

Brolly

(imported comment written by HGA8191)

Hi thanks for the quick response.

Actually what I’m trying to achieve, is to create a report that looks like this:

Exists Key 1 Value ProductName of Key 1 Exists Key 2 Value ProductName of Key 2

Computer A True ABC False N/A

Computer B False N/A True ABCDEFG

Thanks.

(imported comment written by jessewk)

What about a report that looks like the one below? It’s the same information, but existence and value are combined into a single column. If it exists you get the value, if not you get “N/A”.

Value ProductName of Key 1 Value ProductName of Key 2

Computer A ABC N/A

Computer B N/A ABCDEFG

The property definition would be:

if (exists value “ProductName” of keys “HKLM…” of registry) then ((value “ProductName” of keys “HKLM…” of registry) as string) else (“N/A”)

You’d make 2 of the above properties, and then you can do a computer properties report in Web Reports, or just use the console and copy the column results to your spreadsheet/database of choice.

(imported comment written by HGA8191)

Thanks for your help,

Actually this does help a bit, but the purpose of this report is to correct an issue with several keys that exists on some workstatins that have an existent but empty key.

So The key exists but nothing is on that key. So the point of that report is find and eliminate those keys. Thats is why i need to check if the key exists and then if it contains info.

Maybe I can get this by modifying a little bit the code you provided?

Thanks.

(imported comment written by jessewk)

Actually, the query I gave will have return the empty string for the value of the key. So in the report the entry in the column would just be blank.

You could make it more explicit by printing a different string if the value is blank:

if (exists value “ProductName” of keys “HKLM…” of registry) then (if (value “ProductName” of keys “HKLM…” of registry = “”) then (“No Value”) else ((value “ProductName” of keys “HKLM…” of registry) as string)) else (“N/A”)

(imported comment written by HGA8191)

Thanks! that is exactly what I need. However now I’m having the following problem: Everytime I try to add the above relevance into a custom report, I get that the registry is not a defined operator. however if I run the relevance in QnA it works ok. ??

(imported comment written by jessewk)

That’s the correct behavior. The console does not have access to the client inspectors.

Client inspectors are things like ‘registry’ ‘file’ ‘folder’ ‘drive’, etc. Basically, inspectors that apply to a specific machine. These inspectors are available in QnA and to the client.

The console/web reports has it’s own set of inspectors we call ‘session inspectors’. The session inspectors look at the data held by the console/web reports. Examples include ‘bes fixlet’ ‘bes property’ ‘bes site’ ‘bes computer’ etc.

You should make a global retrieved property using the relevance above, or embed it in an analysis. Then you can either use the built in reports that display property results, or create a custom report using relevance. If you use a custom report you’ll need to use the session inspectors. In particular, you’d try something like: values of results of bes property “MSI Products”