Microsoft Exchange Server 2003 – Rapid Reboot

Introduction to Exchange Server 2003 Rapid Reboot

Have you noticed that of all the servers in all the world, that Exchange 2003 server takes the longest time to reboot?  This tendency is worst if the Exchange Server is on a Domain Controller, and there are no other Domain Controllers – a classic test network scenario.

Topics for Exchange Server 2003 Rapid Reboot

 ♠

Mission to shutdown Exchange 2003 quickly

The principle is that if you stop the Exchange Service before you reboot the server, then the reboot is much quicker.  It seems as though if you just shut down an Exchange server which is also a Domain Controller, then operating system wants to find other Domain Controllers and tell them that it is shutting down Exchange, this results in a considerable time-out.

Here are the services that you should shutdown, before you restart the operating system:

MSexchangeIS – Store also called information store
MSexchangeMTA – Message transfer agent for routing
MSexchangeSA – System Attendant
MSexchangeSRS – Site replication service

Now you could shutdown these services manually, but its more fun to use a VBScript.

Exchange Monitor from SolarWindsGuy Recommends: The SolarWinds Exchange Monitor

Here is a free tool to monitor your Exchange Server.  Download and install the utility, then inspect your mail queues, monitor the Exchange server’s memory, confirm there is enough disk space and check the CPU utilization.

This is the real deal – there is no catch.  SolarWinds provides this fully-functioning freebie, as part of their commitment to supporting the network management community.

Free Download of SolarWinds Exchange Monitor

Example – To Shutdown Exchange 200x server

Please realize that my script will shutdown your Exchange services.  So either run it on test server, or change the values for strExServiceX to relatively harmless services like Alerter or BITS.

Instructions

  1. Copy and paste the script below into notepad.
  2. Save the file with .vbs extension e.g. StopService.vbs
  3. Double click and then check the message box.
  4. Check the Services.
  5. Note: This script does not shutdown the server, so either reboot manually or add extra code as explained in the Challenges.
  6. Note: If you do not have an Exchange 200x server, then alter the strExServices to Alerter, BITS or other suitable services.
 

‘ StopService.vbs
‘ Author Guy Thomas https://computerperformance.co.uk
‘ Version 2.7 – March 2005
‘ —————————————-‘

Option Explicit
Dim objService, objWMI, colListOfServices, intExSrv
Dim strExService1, strExService2, strExService3, strExService4
Dim strComp, strWMIsrv

‘  Amend strExService if you do not have exchange e.g. Alerter
strExService1 = "MSexchangeIS"
strExService2 = "MSexchangeMTA"
strExService3 = "MSexchangeSA"
strExService4 = "MSexchangeSRS"
intExSrv = 1

‘ Loops through all the Exchange services
‘ Uses Select Case rather than If then Elseif, end if.
For intExSrv = 1 To 4
   Select Case intExSrv
      Case 1 strWMIsrv = strExService1
      Case 2 strWMIsrv = strExService2
      Case 3 strWMIsrv = strExService3
      Case 4 strWMIsrv = strExService4
   End Select

WScript.Echo "strWMIsrv = " & strWMIsrv

‘ Section using WMI to interrogate the services
‘ Note "." means local computer.
‘ Note strWMIsrv in Line 37 (ish)

strComp = "."
Set objWMI = GetObject("winmgmts:\\" & strComp & "\root\cimv2")
Set colListOfServices = objWMI.ExecQuery("Select * from " _
& "Win32_Service Where Name =’" & strWMIsrv & "’")

‘  See how it cycles through colListofServices until it gets a match
‘  Then stops the objService
     For Each objService in colListOfServices
     objService.StopService()
     Next
Next
WScript.Echo "Now check: Services, MS Exchange xx" & vbCr _
& "This script cuts the time it takes to reboot your Exchange server."

WScript.Quit

‘ End of Script

Learning Points

Note 1:  I am fond of Select Case, where ever possible I use this construction in preference to endless: if, then, elseif, elseif, elseif, endif. 

Note 2: The heart of the script is GetObject("winmgmts…)  Here is where VBScript employs WMI to manipulate the operating system.

Note 3: Many of these WMI scripts use collations. (Like a collection.)  Observe the:  For Each objService in colListOfServices

Challenges

Amend the script to start services.  Starting the services is fun for testing, useful in production.  Example, change line 41 (ish) objService.StartService()

Add a shutdown command at the end of the script, for example:
shutdown /l /t:20 /r  (Lower case L means local, t means time delay in seconds, r means reboot).  See more in Ezine 45 shutdown command

Guy Recommends : SolarWinds’ Free VM MonitorSolarwinds VM Console Free Download

The best feature of this new this new version of SolarWinds VM Monitor is that it checks Windows Hyper-V.  Naturally, it still works with virtual machines on VMware ESX Servers.  VM Monitor is a clever desktop tool that not only tests that your server is online, but also displays the CPU and memory utilization for each node.

It’s easy to install and to configure this virtual machine monitor, all you need the host server’s IP address or hostname and the logon info. Give this virtual machine monitor a try – it’s free.

Download your free copy of SolarWinds VM Monitor.

Summary – Shutdown Exchange Services

You may have noticed that Exchange takes much longer to shutdown than other servers, for example SQL or even Windows 2003.  This problem is worse where Exchange is on a Domain Controller.  The trick is to shutdown the Exchange Services before you shutdown the Windows services.  We achieve this mission with a classic VBScript.

See Also