Script I have updated and can send alerts when servers hit below a certain space threshold. Please feel free to copy and edit the variables as needed. Use task scheduler to run daily.

[cc lang=”Powershell”]
##################################
# )\___/( #
# {(@)v(@)} #
# {|~~~|} #
# {/^^^\} #
# `m-m` #
##################################
# WiseOwl Scripts – Checks all phsyical drives running low on space and emails an alert. Setup up to run in Task Scheduler for daily checks.

# Drives to check: set to $null or empty to check all local (non-network) drives – Make changes accordingly
# $drives = @(“C”,”D”);
$drives = $null;

# The minimum disk size to trigger a warning alert.
$minSize = 15GB;

# SMTP configuration: Edit username, password, Mail Host, and Recipient for successful mail flow
$email_username = “Email”;
$email_password = “yourpassword”;
$email_smtp_host = “”;
$email_smtp_port = 25;
$email_smtp_SSL = 0;
$email_from_address = “”;
$email_to_addressArray = @(“User1@”, “User2@”);

if ($drives -eq $null -Or $drives -lt 1) {
$localVolumes = Get-WMIObject win32_volume;
$drives = @();
foreach ($vol in $localVolumes) {
if ($vol.DriveType -eq 3 -And $vol.DriveLetter -ne $null ) {
$drives += $vol.DriveLetter[0];
}
}
}
foreach ($d in $drives) {
Write-Host (“`r`n”);
Write-Host (“Checking drive ” + $d + ” …”);
$disk = Get-PSDrive $d;
if ($disk.Free -lt $minSize) {
Write-Host (“Drive ” + $d + ” has less than ” + ($minSize / 1GB) `
+ ” Gigabytes free (” + ($disk.free / 1GB) + “): sending e-mail…”);

$message = new-object Net.Mail.MailMessage;
$message.From = $email_from_address;
foreach ($to in $email_to_addressArray) {
$message.To.Add($to);
}
$message.Subject = (“[RunningLow] WARNING: ” + $env:computername + ” drive ” + $d);
$message.Subject += (” has less than ” + ($minSize /1GB) + ” Gigabytes free “);
$message.Subject += (“(” + ($disk.Free / 1GB) + “)”);
$message.Body = “Hello there, `r`n`r`n”;
$message.Body += “this is an automated e-mail “;
$message.Body += “sent by WiseOwl IT low disk space P/S script “;
$message.Body += (“to inform you that ” + $env:computername + ” drive ” + $d + ” “);
$message.Body += “is running low on free drive space. `r`n`r`n”;
$message.Body += “————————————————————–“;
$message.Body += “`r`n”;
$message.Body += (“Machine HostName: ” + $env:computername + ” `r`n”);
$message.Body += “Machine IP Address(es): “;
$ipAddresses = Get-NetIPAddress -AddressFamily IPv4;
foreach ($ip in $ipAddresses) {
if ($ip.IPAddress -like “127.0.0.1”) {
continue;
}
$message.Body += ($ip.IPAddress + ” “);
}
$message.Body += “`r`n”;
$message.Body += “`r`n”;
$message.Body += (“Used space on drive ” + $d + “: ” + ($disk.Used / 1GB) + ” Gigabytes. `r`n”) ;
$message.Body += (“Free space on drive ” + $d + “: ” + ($disk.Free / 1GB) + ” Gigabytes. `r`n”) ;
$message.Body += “————————————————————–“;
$message.Body += “`r`n`r`n”;
$message.Body += “This warning will be emailed when the free space is lower “;
$message.Body += (“than ” + ($minSize / 1GB) + ” Gigabytes `r`n`r`n”);
$message.Body += “Sincerely, `r`n`r`n”;
$message.Body += “– `r`n”;
$message.Body += “WiseOwl IT`r`n”;

$smtp = new-object Net.Mail.SmtpClient($email_smtp_host, $email_smtp_port);
$smtp.EnableSSL = $email_smtp_SSL;
$smtp.Credentials = New-Object System.Net.NetworkCredential($email_username, $email_password);
$smtp.send($message);
$message.Dispose();
write-host “… E-Mail sent!” ;
}
else {
Write-Host (“Drive ” + $d + ” has more than ” + ($minSize / 1GB) + ” Gigabytes free: nothing to do.”);
}
}
[/cc]