1. 程式人生 > >檢查DHCP IP分配情況

檢查DHCP IP分配情況

free peid address dom 告警 mes shtml mtp tostring

檢查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)
}
}
}

檢查DHCP IP分配情況