Skip to content
Menu

Disk Space Below Threshold

Alerts when any fixed drive's free space falls below your percentage. One row per drive, with removable and excluded drives left out.

Disk space below threshold is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Disk space below threshold. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM or a user
NeedsPowerShell 5.1
Read-onlyReads, changes nothing

What It Does

The script reads every fixed drive's size and free space, compares the free percentage with ThresholdPercent, and writes one row per drive. It alerts when any drive is below the threshold.

Removable drives such as USB disks are skipped unless IncludeRemovable is true. Network drives, CD drives and drives without a size, such as a locked BitLocker volume, are always skipped. Drives you name in ExcludeDrives are left out.

Pair it with clear-disk-space when the system drive is the one that fills.

Before You Run It

  • Pick a threshold that suits the drive size. Ten percent of a small drive is far less room than ten percent of a large one.
  • Exclude backup and data drives that are meant to run full, or they will alert every time.
  • It runs as SYSTEM or as a user, so it works in any RMM's monitor slot.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 10 seconds.
  • Example answer: "C: 8% free (31 GB of 400 GB); threshold 10%"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • ThresholdPercent: Alert when free space is below this percentage. Whole number, 1 to 99. Default 10.
  • IncludeRemovable: Also check removable drives (USB disks). true or false. Default false.
  • ExcludeDrives: Drive letters to skip, separated by commas, e.g. "D:, E:". Default none.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-disk-space.ps1 · 775 lines · 38.9 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.