API Report Replicating Impacted Devices on the Software Page (By Days Exposed)

  • 30 March 2021
  • 0 replies
  • 3 views

Userlevel 5
  • Automox Employee
  • 37 replies

This report is similar to viewing the software page, but it only reports the number of impacted devices (devices needing the patch) ordered by days exposed. It will look something like this:



You’ll need to set the following before running the script:


$apiKey = 'YOUR_API_KEY' - in your console, go to Settings->API and select the API key. Note that the API key is per admin user, so you and another admin in your console will have different API keys.


$orgID = 'YOUR_ORG_ID' - put in your Org ID which can be found by looking at the URL on the dashboard and selecting the value after the “?o=”: [https://console.automox.com/dashboard?o=1234]. In this example, the Org ID is 1234.


$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'
$filepath = "C:\Temp\software_not_installed.csv"

$page = 0
$limit = 500
$data = @()

Write-Output "Page"

while($true) {

$headers = @{"Authorization" = "Bearer $apiKey" }
$url = "https://console.automox.com/api/orgs/$orgID/packages?l=$limit&p=$page"
$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json

Write-Output $page
$data += $response | Where-Object {$_.installed -EQ $False}
$page += 1

if($response.count -lt $limit) {
break
}
}

$data | Group-Object display_name,version,os_name,os_version `
| Select-Object @{n='display_name';e={$_.Group[0].display_name}},
@{n='version';e={$_.Group[0].version}},
@{n='os_name';e={$_.Group[0].os_name}},
@{n='os_version';e={$_.Group[0].os_version}},
@{n='severity';e={$_.Group[0].severity}},
@{n='days_exposed';e={(New-Timespan -Start $([Datetime]$_.Group[0].create_time) -End $(Get-Date)).Days}}, Count `
| Sort-Object days_exposed -Descending `
| Export-Csv -Path $filepath -NoTypeInformation

0 replies

Be the first to reply!

Reply