I’m attempting to narrow the results of the following query (stolen from Application Information) to display only applications containing the name “Rational”:
(if (exists value “DisplayName” of it AND (length of (value “DisplayName” of it as string) > 0) AND (number of substrings " " of (value “DisplayName” of it as string) < (length of (value “DisplayName” of it as string)))) then (value “DisplayName” of it as string & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else (""))) else (name of it & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else ("")))) of keys whose (exists value “UninstallString” of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
I’ve tried adding AND (value “DisplayName” of it as string contains “Rational”) in SEVERAL different spots with no success.
I think the problem you were running into was with the high-level if-else stmt, where you use DisplayName value if it exists, otherwise you use the key name. If you qualify the DisplayName piece, the else will just cause all the other values to display the key name instead of DisplayName as opposed to leaving them out completely, which is what you want. Give this a try:
(if (exists value “DisplayName” of it AND (value “Displayname” of it as string contains “Rational”) AND (length of (value “DisplayName” of it as string) > 0) AND (number of substrings " " of (value “DisplayName” of it as string) < (length of (value “DisplayName” of it as string)))) then (value “DisplayName” of it as string & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else (""))) else (if (name of it as string contains “Rational”) then (name of it & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else (""))) else ("") )) of keys whose (exists value “UninstallString” of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
Steve’s way will work, but it will spit out a blank value for each uninstall entry. You can try to limit the results by checking the displayname when iterating through the registry keys:
(if (exists value “DisplayName” of it AND (length of (value “DisplayName” of it as string) > 0) AND (number of substrings " " of (value “DisplayName” of it as string) < (length of (value “DisplayName” of it as string)))) then (value “DisplayName” of it as string & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else (""))) else (name of it & (if (exists value “DisplayVersion” of it) then (" - " & value “DisplayVersion” of it as string) else ("")))) of keys whose (exists value “UninstallString” of it +AND exists value “DisplayName” of it AND value “DisplayName” of it as string as lowercase contains “rational”+) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
I put my changes in italics. It is only in one place.
But…
If you want to search for applications in your deployment, this might be easier:
I have an even better question. How the heck do I get as smart in this as you folks. Seriously. Are there books, classes, etc. that you took to gain advanced knowledge in the BigFix action language?