<#PSScriptInfo .VERSION 1.0.4 .AUTHOR Faris Malaeb .PROJECTURI https://www.powershellcenter.com/ .DESCRIPTION This Powershell module will Place your Exchange Server DAG in maintenance Mode Also you can remove Exchange DAG from Maintenance Mode. Available Commands Start-EMMDAGEnabled: Set your Exchange Server to be in Maintenance Mode. Stop-EMMDAGEnabled: Remove Exchange from maintenanace Mode Set-EMMHubTransport: State Stop and Drain the HubTransport Service Start-EMMRedirectMessage: Redirect Messages in the Queue to another server FQDN Set-EMMClusterConfig: Disable or Enable Cluster Node Set-EMMDBActivationMoveNow: Set Exchange MailboxServer to Block mode so it wont accept mailbox activation request Test-EMMReadiness: Test the environment for readiness to go in maintenance Mode #> Function Check-ScriptReadiness{ param( $ServerName, $AltServer ) if (((Test-NetConnection -Port 80 -ComputerName $ServerName).TcpTestSucceeded -like $true) -and (Test-NetConnection -Port 80 -ComputerName $AltServer).TcpTestSucceeded -like $true){ $isadmin=[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544") switch ($isadmin) { $true {return 1} $false {return 0} } } Else{ write-host "Operation failed, please check if the computer and the Alternative Server are reachable" -ForegroundColor Red Write-host -Message $Error[0] break } } Function Start-EMMDAGEnabled { Param( [parameter(mandatory=$false,ValueFromPipeline=$true,Position=0)]$ServerForMaintenance, [parameter(mandatory=$false)][ValidatePattern("(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?