April 13, 2011

Going Retro– VBSCRIPT to Check Exchange 2003 Cluster Group Node Ownership

What? Exchange 2003? – VBSCRIPT? has Andy gone mad(er) than he normally is – what all this Exchange 2003 and Clustering stuff!

Well there are still a number of organisations running Exchange 2003 whom did not make the jump to 2007 one reason or another (many whom now I suspect are looking directly at the move to Exchange 2010) – so, I believe that whereas I do not blog about Exchange 2003 as much any longer – there is still a large, healthy user base out there – whom some of which might benefit from this script in this post.

The other day I was asked to have a look at an ailing Exchange 2003 Infrastructure (which is based around Exchange 2003 Enterprise Edition configured as an Active/Passive Cluster – with 2 nodes).

Now there are a number of things wrong with this environment – some of which may form the basis of a future posts, but one of the most interesting things that I came across whilst looking at the configuration was the lack of formal monitoring on the Exchange 2003 nodes within the cluster.

In fairness to the organisation concerned the vast majority of their users (some 5000 seats) are running on a dedicated Exchange 2007 CCR environment which is monitored, where this Exchange 2003 setup is a an offshoot installation for a subsidiary company whom should be (and are looking to move to 2010 in the near future) therefore, given that situation; it has been a false economy to purchase a dedicated monitoring product.

However this did not help the situation that they found themselves in, as one of the problems that the installation was experiencing was random failovers between the cluster nodes – which were going undetected as there were no alert functions in place to let the admins know that something had gone wrong.

Now – I will be looking into the cause of the failovers on behalf of the company, however the immediate issue was putting the admins in the position where they did not know when the Exchange Groups (or any other of the associated cluster groups) had failed over to the passive node.

I decided to get them through, it would be an idea to write a simple VBSCRIPT that could be scheduled via the Windows Scheduling Tool (to run every 10 minutes or so) which would check to see if the Passive Node had become the owner of any of the cluster Groups (e.g. a failover of some description had happened). If the script does find an Cluster Group running on the Passive node – it will send an e-mail to the admin – or the email address of a Distribution Group.

The script is provided below (should you wish to copy and paste it into a VBS file on your server):

strComputer = "."
strPassiveNodeName ="<Provide the name of the passive node here>"

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")
Set colItems = objWMIService.ExecQuery("Select * from MSCluster_NodeToActiveGroup")

parseString = "MSCluster_Node.Name=" & chr(34) & strPassiveNodeName & chr(34)

sub send_mail(strSubject,strGroup)
     Set objEmail = CreateObject("CDO.Message")
     objEmail.From = "[email protected]"
     objEmail.To = "[email protected]"
     objEmail.Subject = "Exchange 2003 Cluster Failover Detected - " & strSubject
     objEmail.Textbody = "The follow resources are now running on Node 2: " & strGroup
     objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
     objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<SMTP Server IP Address>"
     objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
End sub

For Each objItem in colItems
     if objItem.GroupComponent = parseString Then
          Wscript.Echo "This node is running cluster services"
          Wscript.Echo objItem.GroupComponent
          Wscript.Echo objItem.PartComponent
          send_mail "Please check",objItem.PartComponent
        WScript.Echo "All Services are running on the primary node"
     End if

If you would like to have a copy of this script already formatted into a VBS file, you can download it from here

Before scheduling the script to run you will need to make that following changes:

Change the strPassiveNodeName ="<Provide the name of the passive node here>" to the NETBIOS name of the Passive Node – for example;

strPassiveNodeName ="prod-Ex2003ND02"

Change the following lines of code within the sub sendMail to reflect a valid sender, recipient address and SMTP Server:

objEmail.From = "[email protected]"
objEmail.To = "[email protected]"objEmail.

Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<SMTP Server IP Address>"

For example

objEmail.From = "[email protected]"
objEmail.To = [email protected]

objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""

When you have changed the relevant values, you should schedule the VBScript to Execute on the PASSIVE node only – every 10 minutes.

Should a failover of any of the Cluster Groups occur, a mail will be sent  to the admins e-mail address letting you know that something is not quite right!

Exchange 2003 Articles, VBScript 3 Replies to “Going Retro– VBSCRIPT to Check Exchange 2003 Cluster Group Node Ownership”
Andy Grogan
Andy Grogan


3 thoughts on “Going Retro– VBSCRIPT to Check Exchange 2003 Cluster Group Node Ownership

    Author’s gravatar

    Great tip and great script Andy.
    I can a question what the stated situation here. The script is a great idea to be alerted if an issues had occur and to check the cluster to ensure that the cluster resources are online along with all the Mailbox Stores.
    Would you suggest a Free Exchange Monitoring tool like the one from SolarWinds that could provide Admins the ability to maintain an eye on the cluster?

    I used these years ago to try it out and don’t believe it had the ability to send email notifications out about the cluster but your script would handle that.
    Could something like the solution from Solarwinds and your script be the ideal non-cost solution for monitoring?

      Author’s gravatar

      Hey Brian, do you know what? I had forgotten all about Solar (bad Grogan, naughty Grogan) as it has been such a while since I last used it 🙂 The key as you point out was the e-mail notification – but you are indeed correct that for a more rounded view of the box in question and a combination with the script it would be a good idea.
      I still have some work to do with this box – I might post back with an update – and Solar will no doubt be part of it 🙂

    Author’s gravatar

    Hi ,

    Iam look for the same script for exchange 2007 SCC…3 node cluster

    If The ClusterMBX server A is move down to Node B, it should trugeer the email

Leave a Reply to ramki Cancel reply

Your email address will not be published. Required fields are marked *

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

Do NOT follow this link or you will be banned from the site!
%d bloggers like this: