API - 3rd Party Report - Updates Available or Applications Installed

Summary

This API script can be used to view all third-party apps available to install or those that are already installed. You can also set whether it only gives Automox-supported apps or includes apps that Automox does not currently support.

 

Setting User-Defined Variables

$apiKey - The API key can be found by clicking on the three dots in the upper-right of the Automox console, and then selecting Secrets & Keys.  Scroll to the API section at the bottom.  If you have an API key, copy it.  If you don't, "Add" one.  Set $apiKey to that value.

$orgID - Look at your browser’s address bar after logging in—the org ID is the number that appears after the equals sign (o=) in the URL.
Example: https://console.automox.com/dashboard?o=123456 (your org ID is 123456).

$managed -  0 = Automox supported apps, 1 = Include apps Automox does not currently support for patching

$available -  0 = Apps already installed, 1 = Updates available, but not installed 

$logFileDir - The directory you want the file saved.

 

PowerShell Script

### User defined ###
$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'
$managed = 0    # 0 = Automox supported apps, 1 = Include apps Automox does not currently support for patching
$available = 1  # 0 = Already installed, 1 = Available, but not installed
$logFileDir = "C:\Temp"
####################

$output = @()
$export = @("Name,Display Name,Version,OS Name,OS Version,Repo")
$page = 0
$limit = 500

if($managed -eq 0) { $man = 'AXsupport' } else { $man = 'nonAXsupport' }
if($available -eq 0)  { $avail = 'Installed' } else { $avail = 'Available' }
$logFilePath = "$logFileDir\3rdParty-$man-$avail.csv"

while($true)
{
    $headers = @{ "Authorization" = "Bearer $apiKey" }
    $url = "https://console.automox.com/api/orgs/$orgID/packages?o=$orgID&awaiting=$available&includeUnmanaged=$managed&limit=$limit&page=$page"
    #$url = "https://console.automox.com/api/orgs/$orgID/packages?o=$orgID&awaiting=0&includeUnmanaged=$managed&limit=$limit&page=$page"
    $response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json
    
    if($available -eq 0)
    { 
        $Output +=  $response | Where-Object {$_.installed -eq $true -and $_.repo -ne "WindowsUpdate" -and $_.repo -ne "WindowsHotfix" -and $_.repo -ne "Apple" -and $_.repo -ne "Linux"}
    }
    else
    {
        $Output +=  $response | Where-Object {$_.installed -eq $false -and $_.repo -ne "WindowsUpdate" -and $_.repo -ne "WindowsHotfix" -and $_.repo -ne "Apple" -and $_.repo -ne "Linux"}
    }

    if($response.results.count -lt $limit) { break }
    $page += 1
}

ForEach ($device in $output)
{
    $serverID = $device.server_id
    $url = "https://console.automox.com/api/servers/$($serverID)?o=$orgID"
    $response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json
    $server = $response | Where-Object {$response.id -eq $serverID}
    
    $export += $server.name+","+$device.display_name+","+$device.version+","+$device.os_name+","+$device.os_version+","+$device.repo
}

$export | Add-Content -Path $logFilePath -Force 

Related Topics

Automox Console API

Was this article helpful?
0 out of 0 found this helpful