Windows
View all Worklets
WindowsWindows

Get Free Disc Space

Report free disk space on Windows fixed drives and flag endpoints below a configurable percentage threshold

Worklet Details

What the free disk space reporter does

This Automox Worklet™ reports the free-disk-space percentage on Windows fixed drives and flags an endpoint as non-compliant when free space falls below a configurable threshold. The remediation script calls Get-CimInstance against the Win32_LogicalDisk class in the root\CIMV2 namespace, iterates each disk where DriveType equals 3 and Size is greater than zero, and computes the free-space percentage by dividing FreeSpace by Size and multiplying by 100.

The default threshold is 10 percent, defined by the $minimumFreeSpace variable at the top of remediation.ps1. Change the value to any integer between 0 and 100 before importing the Worklet, then assign the policy to your Windows workstation or server group. The evaluation phase is a lightweight gate that confirms the endpoint is a Windows host with the SoftwareDistribution directory present, so policy runs against incompatible systems short-circuit cleanly.

The Worklet does not delete files, clear update caches, or change endpoint state. The remediation writes the free-space percentage to standard output, which Automox captures in the policy run record for later review. Because the action is read-only, the same policy can run daily against the entire Windows estate, or on demand through FixNow before a patch window, with no operational risk.

Why audit free disk space across the Windows fleet

Cumulative updates, Windows feature upgrades, and large MSI deployments all need scratch space on the system drive. Feature upgrades stage content in C:\$WINDOWS.~BT and pending downloads accumulate under SoftwareDistribution\Download, and Windows 11 readiness gating refuses to start the install when free space is below the published minimum. A laptop with 4 GB free on the C: drive fails the next Patch Tuesday and produces no obvious signal in the console beyond a missed install.

Capacity remediation is rarely the hard part; identifying the endpoints that actually need it is. A daily Worklet run against your Windows workstation group writes a free-space percentage to the activity log for every targeted host, so a temp-file purge, a user-facing message, or a hardware-refresh ticket can run against a known list of endpoints rather than a guess. Remote and field laptops that never appear on the corporate network surface in the same report as on-premises desktops.

How free disk space reporting works

  1. Evaluation phase: evaluation.ps1 runs Test-Path against $env:allusersprofile\SoftwareDistribution. If the path exists, the script exits 0 and the remediation runs; if it does not, the script exits 1 and the remediation is skipped. This phase only gates platform compatibility – it does not measure disk space.

  2. Remediation phase: remediation.ps1 sets $minimumFreeSpace, calls Get-CimInstance -ClassName Win32_LogicalDisk -namespace root\CIMV2, and loops through every disk where DriveType equals 3 and Size is greater than zero. It computes the free-space percentage as ($free / $size) * 100, rounded to a whole number with [math]::Round. If the resulting value is below $minimumFreeSpace, the script writes a warning with the percentage and threshold and exits 1, flagging the endpoint non-compliant. Otherwise it writes the percentage to output and the endpoint is reported compliant.

Free disk space reporting requirements

  • Windows 7 SP1 or later, including Windows 10, Windows 11, and Windows Server 2012 R2 and later

  • PowerShell 3.0 or higher with Get-CimInstance available (Windows 8 and Server 2012 ship with it; older builds need Windows Management Framework 3.0)

  • The Winmgmt (Windows Management Instrumentation) service running and reachable, since Win32_LogicalDisk lives in the root\CIMV2 namespace

  • Local administrator context for the Automox agent, which the default agent service account already provides

  • Edit $minimumFreeSpace in remediation.ps1 to set the threshold; valid range is 0–100 (integer percent), default 10

  • FixNow compatible, so the same audit can run on demand against any endpoint group from the Automox console for ad-hoc capacity checks before a patch window

Expected output from a free disk space audit

After the Worklet runs, each compliant endpoint exits 0 and the activity log contains a line of the form "Free space" followed by the percentage, for example "Free space 38%". A non-compliant endpoint exits 1 and the log contains "Warning: Free space is at 4%" followed by "Which is below the threshold of 10%". Sorting the policy run by exit code 1 in the Automox console returns the full list of endpoints below threshold.

To validate locally, run Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" | Select-Object DeviceID, @{n='FreePct';e={[math]::Round(($_.FreeSpace/$_.Size)*100,1)}} from an elevated PowerShell session on a sample endpoint and compare the numbers against the Worklet output. From the console, feed the list of non-compliant endpoints into a cleanup Worklet (temp-file purge, Windows Update cache reset) or a ticketing webhook for hardware-refresh follow-up. Because the audit is read-only, the same Worklet can run hourly during a critical patch window without disturbing endpoint state.

View in app
evalutation image
remediation image

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklets deploy named-CVE mitigations within hours of disclosure, perform configuration, remediation, and install or remove applications and settings across Windows, macOS, and Linux.

do more with worklets