Skip to main content

Automox requires a minimum of 3GB of free disk space in order to execute daily functions prioperly. This worklet checks for free disk space on the C:\ drive.



The worklet will produce a result in the Activity Log only if a host has less than 3.0GB of free space on the C:\ drive.



Evaluation:



$runCheck = {



$minDiskSpaceGB = 3.0

$diskCheck = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = '3'" | Where-Object {$_.DeviceID -eq "C:"}| Select-Object -Property DeviceID, @{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}},@{L="Capacity";E={"{0:N2}" -f ($_.Size/1GB)}} | Where-Object {[float]$_.FreeSpaceGB -lt $minDiskSpaceGB}



if ( $diskCheck -eq $null )

{

return 0

}

else {

return 1

}

}



exit $exitCode = & $runCheck



Remediation:



trap {  $host.ui.WriteErrorLine($_.Exception); exit 90 }



$runCheck = {



$minDiskSpaceGB = 3.0

$diskCheck = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = '3'" | Where-Object {$_.DeviceID -eq "C:"}| Select-Object -Property DeviceID, @{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}},@{L="Capacity";E={"{0:N2}" -f ($_.Size/1GB)}} | Where-Object {[float]$_.FreeSpaceGB -lt $minDiskSpaceGB}



return $diskCheck.FreeSpaceGB

}



Write-Output "AX Compatibility Failure: insufficient disk space on host $gc $env:computername"

Write-Output "Free space:"



Invoke-Command $runCheck

Write-Output "GB"

The response from the servers API endpoint also includes free space information in detail.VOLUME. Filter the volumes to where IS_SYSTEM_DISK=true and VIOLA! Very handy for anticipating problems for upcoming scheduled patching events.



Retrieve details for all devices - Automox API Reference Guide


Yes, indeed very useful via API call cgreggo – thanks for pointing that out! Two ways to accomplish the goal here: one API-centric an the other UI-centric.


Yes, very much appreciate the flexibility to ask the questions in both UI and API. Thanks!


Is it possible for Automox to email alerts or for the alerts to show on the dash board when you first login rather than having to hunt for the alerts?


Hi Tina,



The alerts cannot currently display on a dashboard, but you could definitely configure the Remediation part of the script to email you each time a specific host fails the free space check.



Here is a generic PowerShell example of sending an email:



Send-MailMessage -From 'User01 <user01@fabrikam.com>' -To 'User02 <user02@fabrikam.com>', 'User03 <user03@fabrikam.com>' -Subject 'Free Disk Space Issue:' -Body "Low disk space on host X" -SmtpServer 'smtp.yourmailserver.com'



Of course you would want to modify this to meet your specific recipients, your SMTP server, the message body, etc.


Reply