If backups should fail, or there is a mail storm…
How can I get alerted when the Exchange database transaction log disk is almost full?
It’s not a good day when the database dismounts because the TL disk fills up.
The info below is a script that will email you an alert when the TL disk gets under 10%
When a logical drive gets to 10% free (DiskSpaceThreshold) or 400MB left (LowDiskSpaceMinimum), the system log has an event ID 2013 generated.
These are defaults built into the OS.
If you want to change either of these settings, you have to create the registry key.
I assume you don’t have an enterprise program such as SCOM that monitors events… well then this powershell script is for you.
I created a task in task scheduler. I called it “LowDiskSpaceEventID2013”. I manually ran it to make sure it works properly, hence the last run time. (I had it send email to me while testing)
We probably want to change who it runs as, like a service account….
If I click on “Edit”, it has these properties
I put the script in the D:\WorkingFiles folder, the script is called SendMail.ps1. See the attached file.
The powershell script that can email someone internally.
If I point the server to itself when sending out, I get this error
The whole script looks like this
#SMTP server name $smtpServer = "ex02.domain.local" #Creating a Mail object $msg = new-object Net.Mail.MailMessage #Creating SMTP server object $smtp = new-object Net.Mail.SmtpClient($smtpserver) #Email structure $msg.From = "firstname.lastname@example.org" $msg.ReplyTo = "email@example.com" $msg.To.Add("firstname.lastname@example.org") $msg.subject = "Low Disk Space on EX01" $msg.body = "Event ID 2013 has been generated on EX01. Disk space is below 10% or 400MB" #OR #$msg.IsBodyHTML = $true #$msg.body = get-content .moves.htm #Sending email $smtp.Send($msg)
I exported the task to an xml file.
Then I imported this task on the other exchange servers.
I copied the script and modified it for each server
The email message looks like this: