Skip to main content

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

  • February 5, 2021
  • 0 replies
  • 141 views

Tony-Automox

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.

$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

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings