Skip to main content

I’ve taken @jarod.smilkstein’s code from here.

 

There’s 3 things to change in this code to make it work:

 

 

  1.  
  2. put in your API key
  3. put in your orgID
  4. set the $limit variable to the size you want, with a maximum of 500

     

 

 

This code will pull down all your device info via the https://console.automox.com/api/servers

API call, but you can sub that out for whatever info you’re wanting to pull. The data is saved to a csv, but you can also do manipulation to the $data object in the script first before outputting any data.

 

 

You can use this example code to update any of your existing scripts that were created prior to the API limits.

 

 

$apiKey = 'YOUR_API_KEY'

$orgID = 'YOUR_ORG_ID'

$page = 0

$limit = 5



$data = @()

while($true) {

$uri = "https://console.automox.com/api/servers?o=$orgID&api_key=$apiKey&l=$limit&p=$page"

$resp = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | ConvertFrom-Json | Select-Object results

$data += $resp.results



if($resp.results.count -lt $limit) {

break

}

$page += 1

}





$data | Export-Csv -Path .\AutomoxAPI_Export.csv -NoTypeInformation -Force

Here’s how I did it in Python: 

 

page = 0
data = a]
while page >= 0:
url = 'https://console.automox.com/api/servers?o=<<o_id>>&limit=500&page=' + str(page)
r = requests.get(url, headers=automox_headers)
if r.json() == ]:
break
data.extend(r.json())
page = page + 1

 

 


Reply