DHCP pool monitor


#DHCP Percent of Addresses Remaining Threshold

$DHCPLowPercentThreshold = 10

#From Email Address

$FromAddress = “dhcpalert@domain.com”

#To Email Address

$ToAddress = “user@domain.com”

#SMTP Server Address

$SmtpServerAddress = “mail.domain.com”

 

$5MinutesAgo = [DateTime]::Now.AddMinutes(-5)

$DHCPLowEvent = @(Get-EventLog -LogName “System” -After $5MinutesAgo -InstanceID 1020)[0]

$DHCPLowEventMessage = $DHCPLowEvent.Message

$DHCPLowPercent = 100 – $DHCPLowEvent.ReplacementStrings[1]

If ($DHCPLowPercent -le $DHCPLowPercentThreshold){

$messageParameters = @{

Subject = “Warning: DHCP Addresses Low”

Body = “$DHCPLowEventMessage”

From = $FromAddress

To = $ToAddress

SmtpServer = $SmtpServerAddress

}

Send-MailMessage @messageParameters

}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: