Use API to Determine if a Certain Software is Installed on All Devices

This was originally written for a customer that wanted to see if every system in their environment had Sophos Antivirus installed or not - and what version if they did.

$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.

$appInstalled = 'APPLICATION' - put the name of the application as it is listed in the software section of a device’s page that has it installed.

$filepath - The save location and file name for the .csv file generated.

Here’s a sample output checking for Microsoft Edge Chromium:
2020-12-07 14_12_24-AppInstalled - Google Sheets

$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'

$appInstalled = 'Microsoft Edge'
$filepath = 'C:\Temp\AppInstalled.csv'

Set-Content $filepath -Value "Computer,Name,Version"

$apiInstance = 'https://console.automox.com/api/'
$apiTable = 'servers'
$orgAndKey = "?o=$orgID&api_key=$apiKey"

# Put components together
$getURI = $apiInstance + $apiTable + $orgAndKey

# Get the json body of the Web Request
$jsonReturn = (Invoke-WebRequest -UseBasicParsing -Method Get -Uri $getURI).Content

# Convert to object with manipulatable properties/values
$servers = $jsonReturn | ConvertFrom-Json
$servers = $servers | Sort-Object name

# Check each server for software
foreach ($server in $servers) {

    $serverID = $server.id
    $serverName = $server.name
    
    $orgAndKey = "/$serverID/packages?o=$orgID"

    # Put components together
    $getURI = $apiInstance + $apiTable + $orgAndKey

    $headers = @{ "Authorization" = "Bearer $apiKey" }
    $response = (Invoke-WebRequest -Method Get -Uri $getURI -Headers $headers).Content | ConvertFrom-Json

    $installed = $response | Where-Object {$_.installed -EQ $true -and $_.display_name -EQ $appInstalled}

    $output = $serverName + "," + $installed.display_name + "," + $installed.version
    $output | Add-Content -Path $filepath

}
1 Like