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!
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!
Best answer by jack.smith
This will be unconventional… But there is a way.
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
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.