Script | Export all applied patches from all company machines to CSV

  • 28 October 2020
  • 0 replies

Userlevel 3


Thought I would share this API script I wrote that exports all applied patches on all machines to a CSV.

UseCase: For audits this allows an easy way to export every single patch on a machine to prove that machines have been patched during a time period.


  • This is meant to be run on a machine NOT through a worklet.

  • Make sure to add in your own API Key for this to work.

  • For a full list of objects you can pull from the API see Automox API Documentation under “Response”.

  • This script is not perfect. If run multiple times it will keep adding to the same CSV, so make sure to either clear the CSV and save or just delete it.

Powershell Code:

#Set Execution policy to allow for 3rd party modules
Set-ExecutionPolicy Unrestricted -Force

#Define API Key and URL to get initial Machine list
$apiUrl = ""
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer $apiKey")

$response = Invoke-RestMethod $apiUrl -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json

$name = $;
#For each machine get the patch info according to machine ID and Org.
foreach($server in $response){
#Define Server ID, Org ID, and Group ID.
$id = $
$organization_id = $server.organization_id
$server_group_id = $server.server_group_id

$apiUrl = "$($id)/packages?o=$($organization_id)"
$response = Invoke-RestMethod $apiUrl -Method 'GET' -Headers $headers -Body $body
#Define which objects you want to be included in the CSV. See (Under "Response") for full list:
$DesiredProperties = $response | Select-Object $, installed, create_time, display_name, package_id, software_id, cve_score
#Add the information to the CSV.
$DesiredProperties | ConvertTo-Csv -NoTypeInformation | Add-Content -Path "C:\temp\patch_output.csv"

0 replies

Be the first to reply!