API delivers different computer ID's than the Console

Hi,

I’m retrieving computers that match specific parameters. This works just fine for most of the computers except a few Mac OS clients. There is no correlation between the version of the Mac OS and this problem.

What I am doing, this is all automated, scripted, using the BigFix API:

  1. Get devices that have a value in PropertyX but are missing a value in PropertyY. Include the computer ID, computer name and PropertyX.
  2. Using the list, we talk to another system to get values for PropertyY for each computer, creating a new list with the results.
  3. Use the API to create actions to populate PropertyY.

The computer ID is used as the unique identifier through this process.
Here is the session relevance to retrieve the computers.

(
    id of item 0 of it
  , (if exists (name of item 0 of it) then (name of item 0 of it) else "HasNoName") of it
  , (if exists results (item 0 of it, item 1 of it) then values of results (item 0 of it, item 1 of it) else "Unknown_NotReported") of it
) of (
    elements of item 0 of it
  , elements of item 1 of it
) of (
    set of bes computers whose ((not exists client setting whose (name of it as lowercase = "PropertyY" as lowercase) of it) AND (locked flag of it is not TRUE) AND (exists client setting 
whose (name of it as lowercase = "PropertyX" as lowercase) of it) AND (if exists property "in proxy agent 
context" then (not in proxy agent context) else true))
  , set of bes properties whose (name of it as lowercase ="PropertyX" as lowercase)
)

Example XML of the Action, this has been edited to remove the code to show what the end result for a single computer may look like:

<?xml version="1.0" encoding="utf-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SkipUI="true">
    <SingleAction>
        <Title>Automation_Add SAP Account Setting_ALL_1.0</Title>
        <Relevance>(version of client >= "6.0.0.0") AND ((not exists setting "PropertyY" of client) OR (((not exists effective date of it) OR (not exists value of it)) of setting "PropertyY" of client))</Relevance>
        <ActionScript>if {computer ID equals 123456789}
    setting "PropertyY"="ValueY" on "{now}" for client
endif</ActionScript>
        <SuccessCriteria />
        <Settings>
            <HasEndTime>true</HasEndTime>
            <EndDateTimeLocalOffset>P7D</EndDateTimeLocalOffset>
        </Settings>
        <SettingsLocks />
        <Target>
            <ComputerID>123456789</ComputerID>
        </Target>
    </SingleAction>
</BES>

Anomalous Results:
Our computers ID’s stop at numbers beginning with 167… as the highest numbers but for some Mac OS computers, 52 of them currently, the API returns their ID as 214…+ and up to 377…

When I search for these ID’s in the console in the “Computers” view with the Computer ID column visible, I get no results from the console, this is with hidden and non-relevant content visible using a Master Operator account.

The automation creates one action for each 50 computers and it simply loops over them to create the target computers and the action script. The odd thing is that when the action with these odd computer ID’s is created using the BigFix API, BigFix finds the computers and targets them, but they are shown with different ID’s when inspecting the Action in the console.

But the problem is that the Action Script fails. Sure, the BigFix server is able to match those strange computer ID’s with the correct computers for targeting but the computers themselves do not identify them selves as having those ID’s. The ~“if computer ID equals 123 then apply the setting” fails.

Do you know of a way to get same ID that matches the computers from the API?

To keep in mind for our environment. We are an MSP with multiple on-prem domains and cloud only customers in our BigFix environment. We need to be able to rely on a unique ID for each computer.

Best regards,
Páll

(I made a small edit on your post to fix the code tags. You were so close…when highlighting a section and formatting as code, we have to have a blank line before the start of code).

1 Like

One thing that jumps out at me is this check for ‘native’ agents. This structure is correct for client relevance but not for a Session Relevance query. In Session Relevance, the ‘in proxy agent context’ property does not exist so this if statement always returns a True.

To filter to only Native agents, ignoring plug-in agents & correlation, you can use the ‘agent type’ property from ‘bes computer’. This part of the filter then changes the set of bes computers whose () filter to now include

set of bes computers whose (agent type of it = 'Native' AND (not exists client setting whose (name of it as lowercase = "PropertyY" as lowercase) of it) .... )
1 Like

aaah, I knew this from doing this months ago but had forgotten about it. Thank you and thanks for fixing and informing me about the code tags :slight_smile: