Identify Software Install Count Using PowerShell
Use a PowerShell
Scripting language used for Windows worklets. script to identify software packages installed on every device
A subset of Assets, a general term denoting anything that runs the Automox Agent and is registered with the system. in an organization
A subset of an account. An Automox customer account can be tied to multiple organizations, and users can be invited to, and access multiple organizations. An organization contains users, devices, and policies. referenced by the computer name.
Set-Content line reflects all the fields you add to the Select-Object part of the last line of the script. You'll also want the Set-Content line to have the fields in the same order as the Select-Object.Available fields:
List All Software Packages for All Devices
You need to update three areas in the code to get the script to function:
-
$orgID = 'YOUR_ORG_ID'You will need your Org ID, which can be found by looking at the URL. Select the value after the
?o=
-
$apiKey = 'YOUR_API_KEY'In your console, go to Settings → Secrets & Keys and select the API key.
Note: The API key is per user. Each user will have a unique set of API keys.
$filePath
You can also modify$filepathif you want to change the file name or save it in a different location. Keep in mind that the script overwrites a previously generated file if it exists.
Identify Software Install Count Script
Use this script to identify installed packages on every device in your organization.
See also How to Exclude items using -notlike switch
# Set these -----------------
$apiKey = 'YOUR_API_KEY'
$orgID = 'YOUR_ORG_ID'
$filepath = 'C:\Temp\SoftwareInventory.csv'
# ---------------------------
$page = 0
$limit = 500
$servers = @()
Set-Content $filepath -Value "Computer,display_name,version"
$apiInstance = 'https://console.automox.com/api/'
$apiTable = 'servers'
while($true) {
$orgAndKey = "?o=$orgID&api_key=$apiKey&l=$limit&p=$page"
# Put components together
$uri = $apiInstance + $apiTable + $orgAndKey
$resp = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | ConvertFrom-Json | Select-Object results
$servers += $resp.results
$page += 1
if($resp.results.count -lt $limit) {
break
}
}
$servers = $servers | Sort-Object name
# Check each server for software
foreach ($server in $servers) {
$serverID = $server.id
$serverName = $server.name
Write-Output $serverName
$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
$response | Where-Object {$_.installed -EQ $true} `
| Select-Object @{label=”Computer”; Expression= {"$serverName"}},Display_Name,Version `
| Sort-Object Display_Name | Export-Csv -Path $filepath -NoTypeInformation -Append -Force
}
How to Exclude items using -notlike switch
You can also modify it to do things like not show Windows updates & hotfixes by altering the Where-Object part of the last line of the script. For example:
Where-Object {$.installed -EQ $true -and $.repo -notlike "Windows*"}

