Solved

Show Policy Status using BGINFO

  • 14 January 2022
  • 5 replies
  • 258 views

Userlevel 1
Badge

Does anyone know if you can leverage the Automox API to show the Policy Compliance for a device? We’d like the ability to report the system status policy (EX: Compliant / Non-Compliant) and show this on the desktop using bginfo.

 

Thank you!

icon

Best answer by jack.smith 24 January 2022, 19:43

View original

5 replies

Hi, @JLX89 -- We might need some more info, but I reached out to one of our API gurus and got the following answer: “Not sure we have a specific report that would show them say, the percentage or number of devices in compliance etc...now, they may be able to take the Needs Attention report, and script something that basically calculates the number of devices needing attention vs the total number of devices to determine the number or percentage of devices in compliance, but that sounds like a lot of work to achieve that result.” So I think it could be accomplished, but could require some heavy lifting from someone. We can reach out to our team(s) to see about creating a worklet for this, too. 

Also - there’s a lot of work being done right now on our reporting capabilities. In my own, humble, personal opinion...this is an area where AX needs improvement. But, we’ve got an entire team of engineers dedicated to building out more functionality and reports with more actionable info. So stay tuned! 

Userlevel 1
Badge

Hi, @JLX89 -- We might need some more info, but I reached out to one of our API gurus and got the following answer: “Not sure we have a specific report that would show them say, the percentage or number of devices in compliance etc...now, they may be able to take the Needs Attention report, and script something that basically calculates the number of devices needing attention vs the total number of devices to determine the number or percentage of devices in compliance, but that sounds like a lot of work to achieve that result.” So I think it could be accomplished, but could require some heavy lifting from someone. We can reach out to our team(s) to see about creating a worklet for this, too. 

Also - there’s a lot of work being done right now on our reporting capabilities. In my own, humble, personal opinion...this is an area where AX needs improvement. But, we’ve got an entire team of engineers dedicated to building out more functionality and reports with more actionable info. So stay tuned! 

 

@ChadMc-Automox Thanks for following up with me on this! So in BGInfo, the only item we are trying to tie into the Automox API is if that specific

BGInfo Desktop Example: 

Patch Status: Compliant / Non-Compliant (Automox API) [Compliant (Green), Non-Compliant (Red)]
Host Name: {Computer_Name} (BGInfo)
Service Tag: {Dell_ServiceTag) (BGInfo)

 

Our initial run through your API, we didn’t know if it was a query based on the following:

API Query: https://console.automox.com/api/servers?o=$orgID&api_key=$apiKey
 

I believe we’re just trying to tap into the Device Compliance indicator in the console. 

 

 

Thank you so much for your help!

 

Userlevel 5
Badge +1

This will be unconventional… But there is a way. 

  1. Get data on a policy that has run on said device in last 7 days
  2. Use that data to extract the device ID
  3. Lookup device details by ID

Now that the policy info is collected some more code is needed to then build out the BGInfo solution side of this. 

 


$orgID = 00000 # enter your OrgID
$policy = 000001 # enter your PolicyID
$apiKey = Read-Host "api-key: "

$headers = @{ "Authorization" = "Bearer $apiKey" }

# Look at a policy status from last 7 days
$start = (Get-Date).AddDays(-7)
$start = Get-Date $start -f 'yyyy-MM-dd'
$end = Get-Date -f 'yyyy-MM-dd'
$i = 0

$data = do{
$url = "https://console.automox.com/api/events?o=$orgID&policyId=$policy&limit=500&page=$i&startDate=$start&endDate=$end&device_names=sp14393"
$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json
$response | % {
$name = $_.server_name
$id = $_.server_id
[pscustomobject] @{
host = $name
hostid = $id
status = $_.data.status
timestamp = $_.create_time
}
}
$i++
}
while ($response)

# Taking the data collected and extracting the device ID
$ClientID = ($data | Where-Object host -eq $env:COMPUTERNAME).hostid
$url = "https://console.automox.com/api/servers/$ClientID`?o=$orgID"
$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json

# policy results
$response.policy_status

 

Userlevel 1
Badge

@jack.smith Thanks for providing that information -- that might actually be a good head start. I know that we can see the “ID” under Device Details > System Details > ID. So from testing this out, it seems that I could just use Out-File to a text file and add an expression for something like “$expDir = 'C:\ProgramData\amagent\host_status.txt'” and have BGInfo pull the “status” from the text file. 

 

I’ll give this a shot and report back afterwards. I really appreciate the help!

Userlevel 5
Badge +1

@JLX89 you bet. This post you could leverage the install process using Automox https://wmatthyssen.com/2019/09/11/powershell-bginfo-automation-script-for-windows-server-2012-r2/. Last step being to modify the logon.bgi file to include the TXT file for BGInfo to use. Here is the remaining code to move policy status into a text file with a compliant or non-compliant state.

# Export results to TXT file
$status = $response.policy_status | % {
$status = IF($_.status -eq 1){'Compliant'}else{'Non-Compliant'}
[pscustomobject]@{
policy = $_.policy_name
status = $status
exit_code = $_.status
}
}
$status | out-file C:\BGInfo\Automox.txt

Good luck!

Reply