Skip to main content

Based on a query by @d.mccleskey that support would have to run for customers, I’ve adapted it so that customers can run it for themselves. This query is useful for customers to review their Automox patching configurations and review agent communication/health.



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



# Updated code 3/31/21 so script doesn't break if system(s) in org are missing disk volume info



# Update these variables with your API Key, orgID & save directory/filename

# This script expects the $expDir path to already exist and will overwrite an existing file



$apiKey = 'YOUR_API_KEY'

$orgID = 'YOUR_ORG_ID'

$expDir = 'C:\Temp\health.csv'



$page = 0

$limit = 500

$servers = @()



#############################################################################################################



while($true) {



$uri = "https://console.automox.com/api/servers?o=$orgID&api_key=$apiKey&l=$limit&p=$page"



$resp = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | ConvertFrom-Json | Select-Object results



$OutputVol = $resp.results `

| Select-Object Name, agent_version, needs_reboot, last_disconnect_time, last_refresh_time, pending_patches, patches, `

last_update_time, os_family, os_name, os_version, id, server_group_id, create_time -ExpandProperty detail `

| Where-Object VOLUME -NE $null



$resp = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | ConvertFrom-Json | Select-Object results



$OutputNoVol = $resp.results `

| Select-Object Name, agent_version, needs_reboot, last_disconnect_time, last_refresh_time, pending_patches, patches, `

last_update_time, os_family, os_name, os_version, id, server_group_id, create_time -ExpandProperty detail `

| Where-Object VOLUME -EQ $null



$Output = $OutputVol `

| Select-Object Name, agent_version, PS_VERSION, AUTO_UPDATE_OPTIONS, WSUS_CONFIG, UPDATE_SOURCE_CHECK, WMI_INTEGRITY_CHECK, needs_reboot, `

last_disconnect_time, last_refresh_time, pending_patches, patches, last_update_time, os_family, os_name, os_version, id, server_group_id, create_time -ExpandProperty VOLUME `

| Select-Object Name, agent_version, PS_VERSION, AUTO_UPDATE_OPTIONS, WSUS_CONFIG, UPDATE_SOURCE_CHECK, WMI_INTEGRITY_CHECK, needs_reboot, `

last_disconnect_time, last_refresh_time, pending_patches, patches, last_update_time, os_family, os_name, os_version, id, server_group_id, create_time, IS_SYSTEM_DISK `

,@{

Name = 'Free (GB)'

Expression = { ($_.FREE/1000000000).ToString("#####.#") }

} | Where-Object IS_SYSTEM_DISK -EQ True | Sort-Object Name



$servers += $Output

$servers += $OutputNoVol

$page += 1



if($resp.results.Count -lt $limit) {

break

}



}



$servers | Export-Csv -Path $expDir -NoTypeInformation -Force



Column Definitions:



agent_version: We suggest upgrading all agents to the latest version. Please let us know if you would like any assistance with options or information.



auto_update_options: Provides the Automatic Update options last collected from each agent during the last scan before collecting the environment data. The settings can be set in different ways (1. By the OS Patch Management settings in the Automox group the agent belongs to, 2. If the OS Patch Management settings in the group is set to keep settings, it will be set locally, by GPO, or if there is another management system configuring patch processes). Our best practice is to only use one method to manage the patch management settings. As an example, if you want Automox to manage the settings, set the “Windows and macOS Patch Management” setting to “Disable OS Automatic Updates”, and Set the “Windows Update Source” to either “Windows Update” or “WSUS” depending on where you want the devices of that group to search. Disable other patch configuration settings (example, if you use SCCM/Jamf, stop setting patch configurations via agent settings. If you set Windows Update settings with GPO, remove those settings or set to unconfigured in GPO. The important point is to use only one source to configure these settings. {“ENABLED”: “0”, “OPTIONS”: “off”} for Windows, and {“ENABLED”: “0”, “OPTIONS”: “”} for macOS are the preferred settings. This means that the device will not automatically patch itself, and the Automox policy will define what patches to download, and the schedule for installation.



wsus_config: Gives the WSUS settings defined on the client. WSUS_Server is blank if using Windows Updates as the source, and will list the WSUS server if WSUS is the source. WSUS_Managed, 0 = not WSUS managed, and 1 = WSUS managed. REACHABLE is only relevant if WSUS managed. 0 = Not reachable, 1= Reachable.



update_source_check: Lists if there was an error connecting to the update source, and if it was connected. This will present the devices that failed the update source check visible in the console under compatibility tests.



needs_reboot: The system needs a reboot. Further patching may fail until this happens.



last_disconnect_time: Lists when a device last disconnected from Automox. If it is empty, it is active. You can use this to identify devices that have not checked in recently.



last_refresh_time: Lists the last time a scan was performed. If the date is missing or is very old, the device has either been offline for a substantial period, or the agent is no longer working correctly. Note: if the agent is v 1.0-25 and the device is active, please contact support as there is a script that can help correct the issue and update the agent to the current version.



pending_patches: Number of patches needed based on policy at last successful scan. Can be compared to the “patches” column for analysis for what is available vs targeted to install.



os_version: Review for Automox supported OS versions: https://support.automox.com/help/supported-operating-systems



free (gb): This is useful to identify systems with low or no free space, or systems that are not reporting their hardware inventory properly to Automox. Systems showing < 3GB available will make the device appear as non-compatible.



is_system_disk: Should normally say “TRUE”, but if blank, that means the system is not reporting drive volume information as it should.

Apologies…but may be a bit of a numpty…but how do I actually run the Agent Communication and Health Check Report ?


It’s a script that uses the API, so save the code as a .ps1 file and then run it as follows:


Powershell filename.ps1



You’ll need to put in your own API key and OrgID before you run the script.


Thanks Nic. Appreciated.


Hello,


running the script with appropriate values (I have not changed anything more), getting the following error



Select-Object : Property “VOLUME” cannot be found.


At line:25 char:11


+ | Select-Object Name, agent_version, PS_VERSION, AUTO_UPDATE_ …


*+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*









    • CategoryInfo : InvalidArgument: (@{name=azJbkHos…T17:12:23+0000}:PSObject) OSelect-Object], PSArgumentException*










    • FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand*








unfortunately I do not have sufficient knowledge to understand what should be corrected, because everything looks fine for me… Any ideas, hints please.


Thank you.


@Andriy, try and copy the current script at the top, set the top variables again, and see if you still get the message. I just tested it myself in that way and it was working.


Tried clearing to copy and paste the script and insert my variables, but I am getting the same error as Andriy.


@Tony, yes, this is what I did earlier and now repeated - just copy and set the top variables again, the same error.


I found one or more systems missing VOLUME info which I think is causing the error. I have sent each of you suggestions on fixing the specific systems in question. I’ll have to try and see if I can modify the script to account for that.


@Andriy, @Harlan



I re-worked the code. If you have a chance, can you try the new script to see if it now doesn’t break and reports the systems you have not reporting disk volume information?


@Tony,


the script is now working perfectly, thanks a lot!


When I run this I get and 403 Forbidden result from the Powershell script. I have tried with a couple customers API and ORG iD’s.


Do you have the API key and org ID in single quotes?


yes.


And you’re using the API key and not the Access key?


I totally am. Next time I’ll pay more attention to it. Thanks for your help Tony.


PS C:\Users\ace785\Documents> C:\Users\ace785\Documents\Automox_reporting.ps1
At C:\Users\ace785\Documents\Automox_reporting.ps1:43 char:9
+         | Select-Object Name, agent_version, needs_reboot, last_disco ...
+         ~
An empty pipe element is not allowed.
At C:\Users\ace785\Documents\Automox_reporting.ps1:49 char:9
+         | Where-Object VOLUME -NE $null
+         ~
An empty pipe element is not allowed.
At C:\Users\ace785\Documents\Automox_reporting.ps1:64 char:9
+         | Select-Object Name, agent_version, needs_reboot, last_disco ...
+         ~
An empty pipe element is not allowed.


Reply