Skip to content

Commit

Permalink
Create DiskSpaceMonitor.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
rswio authored Jan 26, 2025
1 parent 08f704a commit 9b7df9e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Monitoring/DiskSpaceMonitor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$Threshold = 20 # Percentage
$Drives = Get-PSDrive -PSProvider FileSystem

foreach ($Drive in $Drives) {
$FreeSpacePercent = ($Drive.Free / $Drive.Used) * 100
if ($FreeSpacePercent -lt $Threshold) {
Write-Output "Low disk space on $($Drive.Root): $FreeSpacePercent% free"
}
}

0 comments on commit 9b7df9e

Please sign in to comment.