Disk Space Alert Notification
This PowerShell script helps system administrators monitor disk space usage on their servers. By setting up alert notifications, administrators can stay informed when disk space is running low, allowing them to take proactive measures to prevent system downtime. This script integrates seamlessly with server management solutions like ServerEngine, ensuring that resources are effectively managed and critical alerts are not missed.
param ( [string]$driveLetter = "C:", [int]$thresholdPercentage = 10 ) # Get the current disk space details $disk = Get-PSDrive -Name $driveLetter # Calculate the used percentage $usedPercentage = ($disk.Used / $disk.Capacity) * 100 if ($usedPercentage -ge (100 - $thresholdPercentage)) { $message = "Warning: Disk space on $driveLetter is below $thresholdPercentage%. Current usage is $([math]::round($usedPercentage, 2))%." # Send an alert notification # This can be modified to send an email or trigger another alerting mechanism Write-Output $message } else { Write-Output "Disk space on $driveLetter is sufficient. Current usage is $([math]::round($usedPercentage, 2))%." }