DAG Management PowerShell Commands
Get DAG Status
Get-DatabaseAvailabilityGroup <dag name> -Status | fl
StartDagServerMaintenance.ps1 script to put the DAG member in maintenance mode
.\StartDagServerMaintenance.ps1 -serverName <server name>
StopDagServerMaintenance.ps1 script to take the DAG member out of maintenance mode
.\StopDagServerMaintenance.ps1 -serverName <server name>
Find DatabaseCopyAutoActivationPolicy for all Servers
Get-MailboxServer | Sort-Object -Property DatabaseCopyAutoActivationPolicy | ft name,DatabaseCopyAutoActivationPolicy -AutoSize
Get Maintenance Status
Get-DatabaseAvailabilityGroup <dag name> -Status | fl Servers, ServersInMaintenance
Get ALL Databases and Active Preference information NEAT
Get-MailboxDatabase | Sort Name | ft Name,ServerName,MountedOnServer, ActivationPreference -AutoSize
Get Databases sorted by Active Server
Get-MailboxDatabase | Sort-Object -Property MountedonServer | ft Name,ServerName,MountedOnServer, ActivationPreference -AutoSize
Get Number of Databases in DAG
(Get-MailboxDatabase).count
Get All databases and Activation Preference information
Get-MailboxDatabase | ft name, server, activationpreference -AutoSize
Get Specific databases and Activation Preference information
Get-MailboxDatabase -Identity ‘<database name>′ | fl name, server, activationpreference
Get Primary Active Manager (PAM)
Get-DatabaseAvailabilityGroup -Identity <dag name> -Status | fl name,primaryactivemanager
Move PAM to another server
cluster.exe <dag name> group “cluster group” /moveto:<server name>
To block DB activation (switch site as needed)
Get-ExchangeServer | where { $_.Site -like ‘DOMAIN.ORG/Configuration/Sites/Site’ } | Get-MailboxServer | Set-MailboxServer –DatabaseCopyAutoActivationPolicy Blocked
Enable DAC Mode
Set-DatabaseAvailabilityGroup –identity “<dag name>” –DatacenterActivationMode DagOnly
Run RedistributeActiveDatabases.ps1 script to re-balance the active database copies across the DAG
.\RedistributeActiveDatabases.ps1 -DagName <dag name> -BalanceDbsByActivationPreference -ShowFinalDatabaseDistribution -Confirm:$false > DagConfig.txt
Remove Server from Dag
Remove-DatabaseAvailabilityGroupServer -Identity <dag name> -MailboxServer <server name>
Add Server to DAG
ADD-DatabaseAvailabilityGroupServer -Identity <dag name> -MailboxServer <server name>
Unblock all databases hosted on a server
Set-MailboxServer –identity <server name> –DatabaseCopyAutoActivationPolicy Unrestricted
Block all databases hosted on Server
Set-MailboxServer –identity <server name> –DatabaseCopyAutoActivationPolicy Blocked
Set Mailbox Database Copy Activation Copy
Set-MailboxDatabaseCopy -Identity EX10MBX02\EX10SRV02 -ActivationPreference 1
To block a database copy from getting activated automatically
Suspend-MailboxDatabaseCopy –identity EX10mbx01\EX10SRV03 –ActivationOnly
To reverse the unblock process
Resume-MailboxDatabaseCopy –identity EX10mbx04\EX10SRV13