检查DHCP IP分配情况,Scop IP分配超过80% 发邮件告警
$SMTPServer = "mail.domain.net"
$FromEmail = "[email protected]"
$ToEmail = "[email protected]"
#IP分配大于80% 发邮件告警
$percentage = 80
#Send-MailMessage -From $FromEmail -To $ToEmail -subject $Subject -Body $body -SmtpServer $SMTPServer -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)
$Statistics = Get-DhcpServerv4ScopeStatistics
if ( $? -eq $True )
{
foreach ($scop in $Statistics)
{
if ($scop.PercentageInUse -gt $percentage)
{
$subject = "DHCP " +($scop.ScopeId).IPAddressToString + " In Use: " + $scop.PercentageInUse
$body = " scop: " + ($scop.ScopeId).IPAddressToString
$body += " InUse: " + $scop.InUse
$body += " Free: " + $scop.Free
$body += " PercentageInUse: " + $scop.PercentageInUse
Send-MailMessage -From $FromEmail -To $ToEmail -subject $Subject -Body $body -SmtpServer $SMTPServer -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)
}
}
}
原文地址:http://blog.51cto.com/13804335/2140897