Server Detail Report - Example API PowerShell Script
Here is an API PowerShell script to export your Device Name, Model, Vendor, and Serial Number into a csv.
If you have tried this, you may have found it can be tricky, as the model, vendor, and serial number are stored in a nested field named detail. This script provides the expanded “detail” column data for each device by name.
Example Code:
#Update these variables with your API Key and orgID. This script expects the $expDir path to already exist.#
$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG'
$expDir = 'C:\Temp'
#############################################################################################################
#Pull server detail from API and export as csv to defined directory
$uri = "https://console.automox.com/api/servers?o=$orgID&api_key=$apiKey"
$responseJson = (Invoke-WebRequest -UseBasicParsing -Uri $uri).Content | ConvertFrom-Json
$Output = $responseJson | Select-Object NAME -ExpandProperty detail | Select-Object NAME, MODEL, VENDOR, SERIAL | Export-Csv -Path $expDir\detail.csv -NoTypeInformation -ForceIf you would like to review all the information in the detail column along with the device name, you can change this section:
| Select-Object NAME, MODEL, VENDOR, SERIAL | Export-Csv -Path $expDir\detail.csv -NoTypeInformation -Forceto this:
| Select-Object * | Out-GridviewThis will output your information in an interactive PS table where you can filter and sort. I suggest using the Out-Grid view as some of the detail columns do export cleanly to a csv. From the PS table, you can sort and filter your data, then copy and paste into another file type of your choice.
Hope this helps!
This discussion is archived and closed to replies. Continue it in the Automox Community Slack.
Discuss on Slack