Exchange 2013 Powershell Commands

Exchange 2013 Database Availability Groups>

After one Exchange server crashed it would no longer join back into the DAG. Here is the solution:
Open up an elevated command prompt and use this:

cluster node Exchange01 /forcecleanup

  • After this is successful open up Failover Cluster Manager. Connect to the DAG and you will only see the one Node Exchange01
  • Right click on Node and select Add Node.
  • Input exchange01 which will work because we ran that previous command.
  • Windows will tell you that you should Validate the configuration before adding the server. (I tried this but after leaving it for over 2 hours it was stuck) so you should select to not validate. Click next a few times and you will now see the second Node.


  • In the EAC you can now successfully open the properties of the DAG as well as mount the databases.







    Exchange 2013 Database Copies

    One Exchange01:
    Add-MailboxDatabaseCopy "MB02DB01" -MailboxServer Exchange01 -ActivationPreference 2
    Update-MailboxDatabaseCopy MB02DB01\srv-exch01-cv -SourceServer Exchange02 -Verbose

    One Exchange02:
    Add-MailboxDatabaseCopy "MB01DB01" -MailboxServer Exchange02 -ActivationPreference 2
    Update-MailboxDatabaseCopy MB01DB01\srv-exch02-cv -SourceServer Exchange01 -Verbose







    Exchange 2013 Mailboxes

    To see what Mailbox Database a specific Mailbox is located in:
    Get-Mailbox -Identity johns | fl database

    To see all of the Mailboxes in a specific Database:
    Get-Mailbox -Database "ServerMB01DB01"

    Move Mailbox to a different database
    New-MoveRequest -Identity johns -TargetDatabase ServerMB02DB01

    If you want to move the same Mailbox again you have to remove the previous request
    Remove-MoveRequest -Identity johns






    Exchange 2013 Move Log / Database Location

    Get-MailboxDatabase ServerMB01DB01
    Get-MailboxDatabase ServerMB01DB01 | fl Name, *path*
    Move-DatabasePath ServerMB01DB01 -LogFolderPath F:\Logs\ServerMB01DB01 -EdbFilePath E:\Exchange\ServerMB01DB01





    Exchange 2013 DAG Maintenance

    If your Exchange servers are part of a DAG you must follow these steps before Updating Exchange:
    On the first Exchange server:
    Set-ServerComponentState Exchange01 -Component HubTransport -State Draining -Requester Maintenance
    Restart-Service MSExchangeTransport
    Set-ServerComponentState Exchange01 -Component UMCallRouter -State Draining -Requester Maintenance
    Redirect-Message -Server Exchange01 -Target Exchange02.contoso.com
    Suspend-ClusterNode Exchange01
    Set-MailboxServer Exchange01 -DatabaseCopyActivationDisabledAndMoveNow $True
    Set-MailboxServer Exchange01 -DatabaseCopyAutoActivationPolicy Blocked
    Set-ServerComponentState Exchange01 -Component ServerWideOffline -State Inactive -Requester
    Maintenance


    Now verify the server has been successfully prepped:
    Get-ServerComponentState Exchange01 | ft Component,State -Autosize
    Get-MailboxServer Exchange01 | ft DatabaseCopy* -Autosize
    Get-ClusterNode Exchange01 | fl
    Get-Queue


    Now install your Exchange updates:

    Now we will undo what we just did to get the server back into the DAG:
    Set-ServerComponentState Exchange01 -Component ServerWideOffline -State Active -Requester Maintenance
    Set-ServerComponentState Exchange01 -Component UMCallRouter -State Active -Requester Maintenance
    Resume-ClusterNode Exchange01
    Set-MailboxServer Exchange01 -DatabaseCopyActivationDisabledAndMoveNow $False
    Set-MailboxServer Exchange01 -DatabaseCopyAutoActivationPolicy Unrestricted
    Set-ServerComponentState Exchange01 -Component HubTransport -State Active -Requester Maintenance
    Restart-Service MSExchangeTransport


    To verify that the all services are backup and running you can run:

    Get-ServerComponentState Exchange01 | ft Component,State -Autosize

    If a service is not started run:

    Set-ServerComponentState Exchange01 -Component ForwardSyncDaemon -State Active -Requester Functional
    Set-ServerComponentState Exchange01 -Component ProvisioningRps -State Active -Requester Functional


    Now repeat on any remaining Exchange servers in the DAG.