Writing a basic script
Here is a simple script that will put a DAG member into maintenance mode and display the result of the component states at the end. We have covered the commands in DAG Maintenance section. The first IF statement will check if the target server is a mailbox server; if it is not, it will exit. I have used the Green Foreground color, but feel free to use a color of your choice based on your Exchange Management shell background. The file name used to save this script is the Start-MaintenanceMode.ps1
file. It takes two mandatory parameters: Server and TargetServerFQDN
. Here is an example of putting mailbox server Exch2
in the maintenance mode. Exch3
is another mailbox server, which is part of the same DAG01
:
<#Start-MaintenanceMode.ps1 –Server Exch2 –TargetServerFQDN Exch3.contoso.com #=========== #Parameters #=========== Param ( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [string]$Server=$env:COMPUTERNAME...