Reports per-volume disk space for all SQL Server data/log volumes, with linear-regression growth forecast (Method B1) from JSON snapshot history and optional backup-history bootstrap (Method B2). Outputs color-coded TXT, CSV, and HTML reports. Warns on low free-space and projected fill dates within 30 days.
Execution Flow
Synopsis
Uses sys.dm_os_volume_stats CROSS APPLY sys.master_files to enumerate every volume hosting a SQL data or log file. A JSON snapshot file accumulates daily readings; a linear least-squares regression over these points yields a per-volume growth rate (GrowthPerDayGB) and estimated days until full. When fewer than MinDataPoints (5) snapshots exist, the backup history bootstrap (Method B2) can seed the regression from msdb.dbo.backupset.
Requires dbatools. Snapshot history is appended atomically using a .tmp file and Move-Item. History older than 400 days is pruned automatically. The HTML report color-codes rows with CSS classes .crit, .warn, and .ok.
Forecast Confidence Levels
Confidence
Criteria
High
≥ 7 data points AND R² ≥ 0.80
Medium
≥ 5 data points AND R² ≥ 0.50
Low
Fewer points, lower R², or bootstrapped from backup history.
Bootstrap forecast from msdb backup history when snapshot data is insufficient.
-NoHistory
Switch
false
Read-only mode — do not append today's snapshot to JSON history.
-EnableException
Switch
false
Throw terminating exceptions.
Return Value
Property
Description
MountPoint
Volume mount point or drive letter.
TotalGB / FreeGB / FreePct
Current disk space values.
GrowthPerDayGB
Estimated daily growth in GB from regression.
DaysUntilFull
Projected days until volume is full.
HistoryDays / DataPoints
Age and count of snapshot history records used.
ForecastConfidence
High / Medium / Low.
ForecastBasis
SnapshotHistory or BackupHistory.
Status
OK / Warning / Critical.
Examples
# Basic report, local instanceGet-sqmDiskSpaceReport# Bootstrap forecast from backup history (new server, no history yet)Get-sqmDiskSpaceReport-SqlInstance"SQL01"-SeedFromBackupHistory# Read-only: report without updating snapshot historyGet-sqmDiskSpaceReport-NoHistory | Where-Object Status -ne"OK"