Library / Windows Server and AD

SERVER-002 · Script

Check Disk Space Across Servers

Checks free space on every fixed drive across many servers at once and flags drives running low.

Version 1.0.0Language PowerShellUpdated November 2026Report only, changes nothing

What it does

Read-only. Connects to each server over WinRM (or DCOM if WinRM is off), reads every local fixed drive and saves a dated CSV in the Reports folder. A drive is Low when it is below either -MinFreePercent or -MinFreeGB. Servers that cannot be reached are listed as Unreachable. Pick servers by name with -ComputerName, or by OU with -SearchBase. With neither, it checks this computer.

Requirements

Windows PowerShell 5.1. Admin rights on the target servers. The ActiveDirectory module (RSAT) only when using -SearchBase.

How to run it

  • Run as: a service account with the directory rights the script lists, or SYSTEM on a domain controller or the server being checked
  • Run from: a domain-joined management server or admin workstation with the RSAT tools, as a scheduled task or from your management tool
  • Script type: PowerShell 5.1, 64-bit
  • User interaction: none; the script never prompts
  • Timeout: 30 minutes for large directories or many servers

Settings

NameWhat it doesOptionsDefault
ComputerNameServer names to check.(none)
SearchBaseOU (distinguished name) whose enabled servers should be checked. Used when -ComputerName is empty.
MinFreePercentLowest acceptable free space, in percent. Default: 10.10
MinFreeGBLowest acceptable free space, in GB. Default: 10.10
ExcludeDrivesDrive letters to skip, for example D: for a drive that is meant to be full.(none)
AlertOnLow (default) exits with code 1 when any drive is low or any server is unreachable. Never always exits 0.Low, NeverLow
ServerOptional domain controller used for the -SearchBase lookup.

Exit codes

  • 0 = All drives above the thresholds
  • 1 = Low drives or unreachable servers (with AlertOn Low)
  • 2 = Script error (see log)

Testing steps

  1. Run it on one test OU, test account or test server and check the output and log.
  2. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  3. Roll out to a small group next, then everyone.

Rollback steps

Report only. Nothing is changed, so nothing needs to be rolled back.

Version and change log

VersionDateChanges
1.0.0November 2026First release.