NLB -Notify When Node Drained

A little code snipped to email you when the NLB node you are Drain Stopping is drained.

I find it handy as it can take a while to drainstop a server. This will check the state of the server and email you when it is stopped. Meaning you can get on with real work. Requires a SNMP server and the NLB RSAT Powershell tools installed


$Computername = "yourserver"
$NodeStatus = get-nlbclusternode -nodename $Computername -hostname $Computername
sleep 60
$NodeStatus = get-nlbclusternode -nodename $Computername -hostname $Computername
until ($NodeStatus.state.NodeStatusCode -eq "Stopped")

$MessageBody = "NLBDrained"
Write-host $MessageBody -foreground red
$smtpServer = ""
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$MailFrom = ""
$msg.From = $MailFrom
$Mailto = ""

ForEach ($element in $Mailto) {
$msg.Subject = "NLB Node $Computername Drained"
$msg.IsBodyHTML = $true
$msg.body = "$MessageBody"


Leave a comment

Your email address will not be published.

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