Exchange Server 2013 Maintenance Mode Script (Start)

This script will automatically execute the steps described in the procedure to perform maintenance on an Exchange 2013 DAG Member, described on the following page:

4.4 Star
13,852 times
Add to favorites
E-mail Twitter Digg Facebook
  • Exchange 2019 Compatibility
    1 Posts | Last post November 11, 2019
  • Usable on Exchange 2016?
    2 Posts | Last post September 20, 2018
    • Hi Michael,
      Can we use the script in our Exchange 2016 environment, or should we make changes to the script in order to be able to use it?
      Best regards,
    • Hi Duncan,
      I don`t have any problem running it on a Exchange 2016 server. But full suport would be nice.
  • not working with Exch2013 CU11
    6 Posts | Last post May 08, 2018
    • Hello Michael,
      I am currently testing your script but when i run it, it says that my server is not an exchange 2013 server (it is, is running ex2013 cu11 and is a multi-role server)
      Is there a logfile that gets outputted which i can look at ?.
      Is the script compatible with the latest versions of 2013 ?
    • can anyone answer my question ?
    • Hi Dave,
      sorry for the belated response... I have been quite busy lately.
      I did not test the script in a while, so I couldn't tell you for sure why it does not recognize CU11 as being an Exchange 2013 server...
      Can you post the output of Get-ExchangeServer | Select AdminDisplayVersion here?
    • I had the same problem with CU11 on Exchange 2013.  It seems to be related to the AdminDisplayVersion.Major.   If I do a Get-Member on:
      $discoveredServer = Get-ExchangeServer -Identity $Server | Select IsHubTransportServer,IsFrontendTransportServer,AdminDisplayVersion
      $discoveredServer.AdminDisplayVersion.Major returns nothing.  It may be that this is the issue.  The script worked on two of my CU11 servers but then would not work on the rest.
    • I too have hit the 'admindisplayversion.major' but with a W10 PS client and Exchange 2013 CU12.
      It would seem that Get-ExchangeServer doesnot return admindisplayversion with the major, minor etc properties and only a string - 'Version 15.0 (Build 1178.4)'.
      To work around this issue I've substituted:
         if($discoveredServer.AdminDisplayVersion.Major -ne "15")
         if($discoveredServer.AdminDisplayVersion -notlike 'Version 15*') both the Start and Stop scripts.
      The scripts no function as expected.
    • (Get-ExchangeServer -Identity "vsalbprdmbx03").AdminDisplayVersion | gm
      Returns different results in PowerShell or Exchange Management Shell
      In EMC, you get the major version
      That's my experience at least on Exchange 2013 CU 19 
      So it works from EMC but not from PowreShell / PowerShell ISE (and yes I've created the Exchange session)
      Am sure I've read about this elsehwere but can't recall
  • Single Exchange 2013 non-DAG
    2 Posts | Last post April 24, 2018
    • I have a single Exchange 2013 server, non-DAG, will this script work on my server as well?
    • This is a bit old and you probably have your answer, but for those looking at this for the first time.  Yes, it will run in a scenario without a DAG.
  • Please fix broken link
    1 Posts | Last post March 06, 2018
    • This link on the page is broken:
  • Permission required to run the script
    1 Posts | Last post February 08, 2018
    • Hi Michael,
      can you please tell me the mnimum permissions required to run pre/post maintenance scripts on multirole Exchange Servers. We want to deligate this task to a dedicated team.
  • Exchange 2010\2013 Co-Existance
    6 Posts | Last post January 18, 2018
    • Migrating to Exchange 2013 (CU10) from Exchange 2010. Running the start script on an Exchange 2013 (Multi-role) box it recognizes that I have a DAG and suspends but does not switchover the mounted databases running on the server.  Both my lab and production environment have this issue... unfortunately no error is provided.
    • Great scripts, thanks for u work!
      before suspend cluster group we often check where is PAM role:
      if it's server we should move role to another server. Right?
      move-ClusterGroup -Name "Cluster Group" -Node AnotherServerName
      and after we pause the cluster node by - Suspend-ClusterNode SerVerName
    • Hi there,
      Thank you for the feedback. As a matter of fact, we are working on creating a newer version of the script which will solve some problems, one of them being what you just described (also checking for the PAM now).
      It should be online in the next few weeks.
    • Did you have a chance to update the script? If not, when do you think you can post the new version?
    • Hey Van Hybrid,
      Any update on that fixed scripted, or what you're changing that will resolve the error listed above? Thanks a lot!
    • The script indeed attempts to switchover the databases with this cmdlet:
      Set-MailboxServer $Server -DatabaseCopyActivationDisabledAndMoveNow $true
      but as explained on Technet this parameter has two exceptions:
      "The DatabaseCopyActivationDisabledAndMoveNow parameter specifies whether to prevent databases from being mounted on this server if there are other healthy copies of the databases on other servers. It will also immediately move any mounted databases on the server to other servers if copies exist and are healthy. Setting this parameter won't cause databases to move to a server that has the DatabaseCopyAutoActivationPolicy parameter set to Blocked."
      The script needs to add a check for servers that have DatabaseCopyAutoActivationPolicy parameter set to Blocked
      After running the script we need to verify that the server is ready for maintenance:
      1. To verify the server has been placed into maintenance mode, run Get-ServerComponentState <ServerName> | ft Component,State -Autosize
      2. To verify the server is not hosting any active database copies, run Get-MailboxServer <ServerName> | ft DatabaseCopy* -Autosize
      3. To verify that the node is paused, run Get-ClusterNode <ServerName> | fl
      4. To verify that all transport queues have been drained, run Get-Queue
      Managing database availability groups
  • Script to undo your start-Maintenance Mode
    1 Posts | Last post July 22, 2017
    • Hi Michael,
      Do you have a script to disable the maintenance mode? Once we completed the maintenance work on the server is there a script to disable the maintenance and put back Exchange into production.
  • Still problems
    1 Posts | Last post May 16, 2017
    • Hello,
      when I start this script I get very often the following error, when I start the script again for a second or third try it runs without errors. Is this known and will be an updated script available in the next time? I´ve also tried the script from José Ramón SG, with the same result.
      Exchange can't connect to the Microsoft Exchange Transport service on computer "servername". Verify that the service is started.
      At C:\Users\username\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\servername.fqdn\servername.fqdn.psm1:18205 char:9
      +         $steppablePipeline.End()
      +         ~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [Get-Queue], LocalizedException
          + FullyQualifiedErrorId : [Server=servername,RequestId=64b97529-7e48-4fca-9b2d-d936d8fc5f8d,TimeStamp=5/9/2017 2:50:27 PM] [FailureCategory=Cmdlet-LocalizedException] A675E03D,Microsoft.Exchange.Management.QueueViewerTasks.GetQueueInfo
      Best regards, Bernd
  • Unexpected Behavior writing informational message
    2 Posts | Last post February 24, 2017
    • This isn't a question per say. Just an observation. There's some sort of error with the outputting of the informational message. Somehow the Write-Host function isn't taking into account the foreground color, and is writing it to host instead.
      Here's what I gathered from my EMS...
      INFO: Sleeping for 60 seconds before checking the transport queues again...
      INFO: Sleeping for 60 seconds before checking the transport queues again...
      INFO: Sleeping for 60 seconds before checking the transport queues again...
    • You probably already found out it yourself, but in the script instead of Write-Hotst it is used Write-Output. So you have just to change it to Write-Hotst.
1 - 10 of 18 Items