I wanted to reach out regarding an exciting development in our toolset. As some of you may know, we’ve been utilizing a PowerShell module to manage client relevances efficiently. However, to enhance compatibility and expand our capabilities, we’ve been exploring the possibility of replicating this functionality in Python.
$expressions = @('if (exists folder ((value "EnterpriseClientFolder" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BigFix\EnterpriseClient" of native registry) as string & "DEX")) then ((not exists (file of folder ((value "EnterpriseClientFolder" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BigFix\EnterpriseClient" of native registry) as string & "DEX")) whose ((name of it = "LastArchivalTime.txt"))) or (exists (file of folder ((value "EnterpriseClientFolder" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BigFix\EnterpriseClient" of native registry) as string & "DEX")) whose ((name of it = "LastArchivalTime.txt") and (now - modification time of it > 24*hour)))) else false', 'if (exists folder ((value "EnterpriseClientFolder" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BigFix\EnterpriseClient" of native registry) as string & "DEX\Results")) then (number of files of folder ((value "EnterpriseClientFolder" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BigFix\EnterpriseClient" of native registry) as string & "DEX\Results") > 0) else false', '(name of it, version of it) of operating system')
foreach ($expression in $expressions){
$relevance = Invoke-EvaluateClientRelevance $expression
$relevance.Answer
}
True
True
Win11, 10.0.22621.3155
I’m not familiar with that PowerShell module. I don’t think I’ve seen anything in Python to call the client relevance evaluator, but I could envision something that either uses the Client Compliance API, or calls the QNA.exe binary and reads the stdin/stdout from it to evaluate relevance
There is a Python Module that can be installed with PIP for interacting with the BigFix REST API which I would highly recommend using for many reasons:
There is also a python script for evaluating relevance locally on a system, which is less useful in many ways, but this actually seems like what you are trying to accomplish:
The example could use enhancements, like the ability to accept the client relevance as file text, or command line arg, stdin, or a string within the script if neither are provided. File text is one of the better options to not have to deal with character escaping, which can become a big pain.
It would also be handy if it could pick 10 target computer ids that have UDP notifications or persistent connections working, which would be more specific than what it currently does.
Would also be interesting to accept a list of computer ids as input somewhere to target, but the default is to target 10 recently reported computers, which is a pretty good option without having a specific target in mind.
It would also be useful to incorporate some of these capabilities as functions within the besapi module itself, and then provide a way to do it within bescmd interactive command prompt.
Originally the besapi python module was as thin as possible wrapper around the BigFix REST API with functions to make it easier to work with in python, but over time I have created more and more helper functions to provide actual outcomes in smart ways, including migrating example functionality from the bescmd interactive command to actual besapi module functions that are then called by bescmd instead.
Now, when implementing a new capability, I generally start with a script here: