Exchange Server Recovery

How to Use Remove-DatabaseAvailabilityGroupServer?


Table of Content

    Summary: If you have issues with one of the members in the Database Availability Group (DAG), then you may need to uninstall and remove it. In this article, we will discuss how to use the Remove-DatabaseAvailabilityGroupServer command in EMS to remove the server from the DAG. We’ll also mention an Exchange repair software that can help in case the database gets corrupted.

    In Exchange Server, with the Database Availability Group (DAG) setup, you may encounter issues with one of the Exchange Server nodes. In such a case, you may need to effectively and safely remove the server from the group. However, you just can’t delete the server from the Active Directory and switch it off as there are various configurations and services that might still be pointing to the removed server. So, this might affect the health and replication of the other nodes in the ­­availability group. Hence, it’s important to safely remove the server.

    You can use the Remove-DatabaseAvailabilityGroupServer command to safely remove the server from the replication group. Below, we’ll be discussing how to use the Remove-DatabaseAvailabilityGroupServer command, along with its functionalities and features.

    Requirements before Running the Command

    There are some requirements that you must meet before running the command and remove the server.

    You need to ensure that the server to be removed does not host any replicated databases and any database from the server is removed.

    You need to ensure that the user you’re using to run the command in PowerShell has enough security rights to perform the process needed to remove the server. If you don’t have enough rights, you will not be able to remove the server.

    To know the permissions and roles you need to run the command, open the Exchange Management Shell (EMS) as an admin and run the following command.

    $Perms = Get-ManagementRole -Cmdlet Remove-DatabaseAvailabilityGroupServer

    Get-ManagementRole

    As you can see (in the above image), you need to be in the following two roles:

    • Database Availability Groups
    • Exchange Server

    Once you set these permissions, you can proceed with the command.

    Run the Command

    Now, to remove the server, you can run the Remove-DatabaseAvailabilityGroupServer command in the Exchange Management Shell (EMS) as given below.

    Remove-DatabaseAvailabilityGroupServer -Identity <availability group> -MailboxServer <server name to remove>

    Remove-DatabaseAvailabilityGroupServer

    The above command will remove the mailbox server with the name SRV002 from the Database Availability Group – DAG001.

    If you want to remove the Exchange Server from the Database Availability Group (DAG) configuration only, then you can use the command as given below.

    Remove-DatabaseAvailabilityGroupServer -Identity <availability group> -MailboxServer <server name to remove> -ConfigurationOnly

    Remove-DatabaseAvailabilityGroupServer -Identity

    Note: Before running this command, you need to ensure that the mailbox server is offline. Also, before running the command, you must evict the server from the cluster as a node. Otherwise, this would create a huge issue. With a cluster, you need more than one node and it must be an odd number. You will lose high availability and could damage your setup with the risk of losing data.

    If you wish to bypass the Database Availability (DAG)’s quorum model validation and health check, you can use the SkipDagValidition switch in the command (see below). However, it is not recommended.

    Remove-DatabaseAvailabilityGroupServer -Identity <availability group> -MailboxServer <server name to remove> -SkipDagValidation

    SkipDagValidition

    You can also use the command with the WhatIf switch to ensure that the command will work and get its output. The command will simulate all the changes without affecting them or saving any changes.

    Remove-DatabaseAvailabilityGroupServer -Identity <availability group> -MailboxServer <server name to remove> -SkipDagValidation -WhatIf

    SkipDagValidation -WhatIf

    What to do if something goes wrong?

    During execution of the command, you may encounter issues. If you do not implement the requirements when running the command, you may encounter the below error.

    WARNING: An unexpected error has occurred and a Watson dump is being generated: The given key was not present in the dictionary. The given key was not present in the dictionary.

    This means that the server is active in the Active Directory. You can resolve this issue by running the setup with recoverserver switch. With this, you can rebuild the server from the schema.

    You may also encounter the following error:

    Mailbox server ‘SRV002’ cannot be removed from the database availability group because mailbox database ‘DB01’ has multiple copies. Use Remove-MailboxDatabaseCopy either to remove the copy from this server or to remove the copies from other servers in the database availability group.

    This means that there are still copies of a database on the server. In such a case, you can use the Remove-MailboxDatabaseCopy command to remove the copies from the server.

    Free Download for Windows

    Conclusion

    Above, we have explained how to use the Remove-DatabaseAvailabilityGroupServer PowerShell cmdlet to remove the server from the DAG. However, before running the cmdlet, you need to fulfil all the requirements and follow the instructions properly. In case you do not follow the recommendations and instructions, or the server has failed or suffered a power loss, then you will end up with a corrupted database.

    In this case, the easy and quick solution is to use a third-party Exchange Server Recovery application, such as Stellar Repair for Exchange. The application can open any version of Exchange Server – be it in a dirty shutdown state. It can recover data from the Exchange database and export it to PST and other formats. It can also directly export the data from EDB file to a live Exchange Server or Microsoft 365.

    Was this article helpful?

    No NO

    About The Author

    Eric Simson linkdin

    Eric Simson is an Email Platform Consultant and is associated with Stellar Data Recovery from last 6 years. He writes about the latest technology tips and provides custom solutions related to MS Outlook, MS Exchange Server, Office 365, and many other Email Clients & Servers.

    Related Posts

    WHY STELLAR® IS GLOBAL LEADER

    Why Choose Stellar?

    • 0M+

      Customers

    • 0+

      Years of Excellence

    • 0+

      R&D Engineers

    • 0+

      Countries

    • 0+

      PARTNERS

    • 0+

      Awards Received