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.5 Star
7,536 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Single Exchange 2013 non-DAG
    1 Posts | Last post February 16, 2018
    • I have a single Exchange 2013 server, non-DAG, will this script work on my server as well?
  • 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.
  • Edge Role
    1 Posts | Last post September 12, 2016
    • Hello Michael.
      I have uploaded a modified script, which starting with your script, includes the logic to the Edge Role. If you are agree, you can update your script with this modifications.
      - Start: 
      - Stop:
      José Ramón.
  • Is it skipping a step when running on my servers?
    1 Posts | Last post August 23, 2016
    • Hello Michael,
      I see that there is a line in the script that states, 'Write-Host "INFO: Done! The components of $Server have successfully been placed into an inactive state!"', but when I run the script it never returns that message.  
      Also, once it completes running and I go in to the EMC it is not showing the database that was on that server activated on the server I specified when running the script.
      I am wondering if my server is actually going in to full maintenance mode.
      Thank you,
  • not working with Exch2013 CU11
    5 Posts | Last post July 06, 2016
    • 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.
  • Can I use this script for Exchange 2016 as well ? bcoz CU1 :-)
    2 Posts | Last post June 03, 2016
    • Michael, hi
      again want to say - great script!
      no updates for this script ?
    • Hey Max,
      I've not had time to work on the script in the past weeks/months.
      It's due for a major overhaul, as there are quite a few things that need to be changed... It's on my to-do list, but no promise as to when I'll get to it.
1 - 10 of 15 Items