Laeeq Qazi's Exchange Server Blog

Exchange Server blog

How to uninstall Exchange Server 2007

I have often seen people searching for the uninstall steps for Exchange 2007, specially for Mailbox Server. Uninstall of Mailbox Server is not difficult at all if steps are performed properly.

Suppose i have following 2 Servers

Exchange01 (HUB+CAS+Mailbox Roles)
Exchange02 (HUB+CAS+Mailbox Roles)

and i want to uninstall any one of them, e.g Exchange02.

So here are the steps to uninstall Exchange02 server (all 3 roles). I run Powershell Commands in EMS for most of the tasks:

First of all uninstall Mailbox Role from Exchange02 Server.

Login to Exchange02 Server using Administrator Account:

Open Exchange Management Shell

1. Move/remove all Offline Address Books for which Exchange02 is OAB Generation Server.

Move of OABs would be good choice and this can easily be done by opening EMC and then browsing to “Organization cofiguration->Offline Address Book” and then selecting any OAB and then clicking Move button on right side in the Action Pane. Perform this step for all OABs on Exchange02 server and move to Exchange01.

You can also remove the OABs on this server using the ps command:

1.1get-OfflineAddressBook -Server Exchange02 | remove-OfflineAddressBook

2. Go to Mailbox server and Remove all Public Folders+System Public Folders

2.1. Get-PublicFolder “\” -Recurse -ResultSize:Unlimited | Remove-PublicFolder -Recurse -ErrorAction:SilentlyContinue
2.2 Get-PublicFolder “\Non_Ipm_Subtree” -Recurse -ResultSize:Unlimited | Remove-PublicFolder -Recurse -ErrorAction:SilentlyContinue

3. Remove PublicFolder Database

3.1 Get-PublicFolderDatabase -server Exchange02| Remove-PublicFolderDatabase

Sometimes if we have more than one exchange Mailbox Servers we get public folder replica error while trying to remove a PublicFolder Database and can not remove the PF DB.

“The public folder database “PublicFolder Database” contains folder replicas. Before deleting the public folder database, remove the folders or move the replicas to another public folder database..”

Solution: Move all replicas to some other server.

There is nice powershell script “MoveAllReplicas.ps1” for this purpose, provided by Microsoft, and placed at
drive:\\Program Files\Microsoft\Exchange Server\Scripts.

Its usage is:
MoveAllReplicas.ps1 –Server currentServer –NewServer NewServerToHoldReplica

So I used:
MoveAllReplicas.ps1 –Server Exchangge02 –NewServer Exchangge01

After running this script I waited for 15 mins and then removed the Public Folders again using both above 2.1 and 2.2 commands for “\” and “\Non_Ipm_Subtree” and then again executed 3.1 command to remove the PF database.

4. Remove all mailboxes (This step will not delete default mailbox for Administrator)

4.1 Get-mailbox -server Exchange02 | remove-mailbox -confirm:$false

5. Now Disable Default Administrator mailbox using the command

5.1 Disable-mailbox Administrator if it exists on Exchange02 server.

6. Now delete all disabled mailboxes on this MBX server

6.1 get-MailboxStatistics -server Exchange02 | Where{$_.DisconnectDate -ne $null}| foreach {remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid }

7. Now open ‘Add/Remove Programs’ and select Exchange 2007 and then press ‘Remove’ button on the right side.
Exchange 2007 Uninstall window will appear and will ask what server roles you want to uninstall.

Now deselect Mailbox Serve role only.
Uninstall will start now and hopefully without any error.

8. Now uninstall HUB, CAS roles and Exchange management Tools using same method as u unistalled MBX server from ‘Add/Remove Programs’.

I hope that this post help you in uninstalling Exchange Server 2007 and specially Exchange 2007 Mailbox Role.
Please feel free to add comments to this post if you find any thing wrong, or want to convey improvement.

Laeeq Qazi

May 28, 2010 - Posted by | Exchange 2007 |


  1. […] How to uninstall Exchange Server 2007 May 2010 4 […]

    Pingback by 2010 in review « Laeeq Qazi' Exchange Server 2007/2010 Blog | January 2, 2011 | Reply

  2. Get-mailbox -server Exchange02 | remove-mailbox -confirm:$false

    THIS WILL DELETE THE ACTIVE DIRECTORY OBJECTS OF THE USERS THAT HAVE MAILBOXES!!! DO NOT DO THIS!!! The proper thing is to disable the mailboxes, you can delete the database after all mailboxes are disabled and then uninstall will proceed.

    Comment by Bryan | March 2, 2016 | Reply

    • Thanks Bryan. That’s good point.
      To disable the mailboxes, the command should be:
      Get-mailbox -server Exchange02 | disable-mailbox -confirm:$false

      Comment by exchangegeek | March 2, 2016 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: