skip to Main Content

Remove last Exchange Server in organization

There is a difference when you want to uninstall the last Exchange Server on-premises or when you want to uninstall one Exchange Server. Also, when should you remove the last Exchange Server in the organization? In this article, we will show you how to decommission the last Exchange Server.

Introduction

Do you have an Exchange Hybrid configuration? Ensure that you first follow these two articles:

  1. Remove Exchange Hybrid configuration
  2. Uninstall Azure AD Connect

In the previous article, we discussed that you need to keep an Exchange Server for management purposes if the Active Directory on-premises remains. However, if you don’t keep an Active Directory on-premises and go entirely to the cloud, you can remove the last Exchange Server.

Suppose you don’t have an Exchange Hybrid configuration and want to decommission the last Exchange Server; you can follow the same steps below.

Before you start

Run Exchange Management Shell as administrator. Then, run the Set-ADServerSettings cmdlet, including the -ViewEntireForest parameter. It will let you view the objects in the entire forest.

[PS] C:\>Set-ADServerSettings -ViewEntireForest $true

Remove move requests

You have to remove all the move requests, or an error shows up in the readiness checks when uninstalling the last Exchange Server. The readiness check will verify that the Exchange Server uninstall setup can continue.

[PS] C:\>Get-MoveRequest | Remove-MoveRequest -Confirm:$false

Remove offline address book

Remove the offline address book.

[PS] C:\>Get-OfflineAddressBook | Remove-OfflineAddressBook -Confirm:$false

Disable mailboxes

Run the below commands to disable all the mailboxes, including the system mailboxes.

[PS] C:\>Get-Mailbox -ResultSize Unlimited | Disable-Mailbox -Confirm:$false

[PS] C:\>Get-Mailbox -ResultSize Unlimited -Archive | Disable-Mailbox -Confirm:$false

[PS] C:\>Get-Mailbox -ResultSize Unlimited -PublicFolder | Disable-Mailbox -Confirm:$false

[PS] C:\>Get-Mailbox -AuditLog | Disable-Mailbox -Confirm:$false

[PS] C:\>Get-Mailbox -Arbitration | Disable-Mailbox -Arbitration -DisableLastArbitrationMailboxAllowed -Confirm:$false

Remove mailbox databases

Remove the mailbox databases.

[PS] C:\>Get-MailboxDatabase | Remove-MailboxDatabase -Confirm:$false

Remove last Exchange Server from control panel

Close all open programs on the Exchange Server. Go to Control Panel and click on Programs and Features. Select the Exchange Server in the programs list. Click on Uninstall.

Note: Disable Antivirus/Windows Defender to speed up the Exchange uninstallation process.

In our example, we will remove Microsoft Exchange Server 2019 Cumulative Update 11.

Remove last Exchange Server in organization programs and features uninstall

Remove Exchange Server

Click next to remove the last Exchange Server from the organization.

Remove last Exchange Server in organization uninstall wizard

Readiness checks

The prerequisite analysis will start and check if the setup can continue with the removal. Click uninstall.

Readiness checks valid

Suppose you get the below error. It means a mailbox database contains one or more mailboxes. Go through the first steps, disable the mailboxes and remove the mailbox databases on the Exchange Server. After that, retry the Exchange Server uninstallation wizard.

Readiness checks error

Below is the error output in an easier to read format:

Error:
Uninstall can't continue. Errors:
This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes or arbitration mailboxes, Audit mailboxes.
To get a list of all mailboxes in this database, run the command Get-Mailbox -Database <Database ID>.
To get a list of all mailbox plans in this database, run the command Get-MailboxPlan.
To get a list of archive mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Archive.
To get a list of all public folder mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -PublicFolder.
To get a list of all arbitration mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Arbitration.
To get a list of all Audit mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -AuditLog.
To disable a non-arbitration mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID>.
To disable an archive mailbox so you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -Archive.
To disable a public folder mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -PublicFolder.
To disable a Audit mailbox so that you can delete the mailbox database, run the command Get-Mailbox -AuditLog | Disable-Mailbox.
Arbitration mailboxes should be moved to another server; to do this, run the command New-MoveRequest <parameters>.
If this is the last server in the organization, run the command Disable-Mailbox <Mailbox ID> -Arbitration -DisableLastArbitrationMailboxAllowed to disable the arbitration mailbox.
Mailbox plans should be moved to another server; to do this, run the command Set-MailboxPlan <MailboxPlanID> -Database <Database ID>.
It was running the command 'Remove-MailboxDatabase 'CN=DBgoogol,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=EXOIP,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=exoip,DC=local' -whatif'.
For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.UnwillingToRemoveMailboxDatabase.aspx

Setup progress

The first step is removing the mailbox service from the mailbox role.

Remove last Exchange Server in organization step 1

Step 5 of 13 is in progress.

Remove last Exchange Server in organization step 5

Step 9 of 13 is in progress, which is stopping the services.

Remove last Exchange Server in organization step 9

Setup completed. Click Finish and reboot the Windows Server.

Remove last Exchange Server in organization setup has completed

Did you get an error when removing the Exchange Server? Read the article An incomplete installation was detected when uninstalling Exchange.

Verify removal Exchange Server

Check that Exchange Server is removed from Programs and Features.

Remove last Exchange Server in organization verify uninstallation

You did successfully remove the last Exchange Server from the organization.

Don’t forget to remove other tools on the Exchange Server, for example, SCOM or the backup agent. After that, remove the IP and DNS entries. Finally, remove the AD object in ADUC (Active Directory Users and Computers).

Keep reading: How to remove Exchange from Active Directory »

Conclusion

You learned how to remove the last Exchange Server in the organization. It’s essential to remove the mailbox databases before you start uninstalling the Exchange Server. Reboot the server when the Exchange Server finishes with the removal.

Did you enjoy this article? You may also like Configure Azure AD Password Protection for on-premises. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has One Comment

  1. These are great tips, like the follow-up about removing traces from Active Directory.

    If I may add some additional steps to consider:
    – As recommended by Remove-MailboxDatabase, manually remove the database files located in C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database…
    – In IIS, confirm the removal of all Exchange websites and references
    – On reinstalling Exchange Server, you may find event log entries like “Property [PreviousDatabase] is set to value… it is pointing to the Deleted Objects container in Active Directory. This property should be fixed as soon as possible.” To clear these, use ADSI Edit to locate the msExchPreviousHomeMD property for each affected user, click Edit and then Clear.

Leave a Reply

Your email address will not be published.