PowerShell - Automation Patterns
You wrote this script to send an email alert if disk space is low:
But no email is sent even when disk space is low. What is the likely problem?
$freeSpace = (Get-PSDrive C).Free
if ($freeSpace -lt "100MB") {
Send-MailMessage -From 'alert@example.com' -To 'admin@example.com' -Subject 'Low Disk Space' -Body 'Disk space below 100MB' -SmtpServer 'smtp.example.com'
}But no email is sent even when disk space is low. What is the likely problem?
