AutomoxAutomox

Use API for a Count of All Software Installed in an Organization (with Pagination)

Tony-Automox
February 5, 2021 at 9:09 pm UTC

This API call will generate a list of all software in your organization and a count of how many are installed of each. Just update your API key, org ID, and where you want the file saved. It will overwrite an existing file if it exists.

It also shows how you can use pagination to account for more than 500 results.

powershell25 lines
$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'
$filepath = "C:\Temp\packages.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
    $page += 1

    if($response.count -lt $limit) {
        break
    }
}
$data | Group-Object display_name | Sort-Object name | Select-Object Count,name `
      | Export-Csv -Path $filepath -NoTypeInformation

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack