In our environments, there may come a time when you need to make changes, for example you may need to retire servers as your footprint is reducing or you have a problematic server that you want to remove, which-ever scenario you are in that involves, it may require uninstalling or hard removing a server. Below is a scenario where two “healthy” servers had to be removed but resulted in having to do some removal in the registry to fix it.
Problem:
In this scenario we were running Windows Server 2019 Core Edition and the uninstall has to take place using the command line as you have not graphical user interface (GUI).
Here are some commands that had to be run to get to the point where we uninstall:
- At the command prompt, type in PowerShell (In Windows Server 2022 Core, PowerShell is already active at the prompt)
- Mount the disk Image (ISO) using the Mount-DiskImage command. e.g “Mount-DiskImage C:\Temp\ExchangeServer2019.ISO”
- Navigate to the location where the ISO was mounted, in this example it was the F:\ drive. Type F: at the prompt and press enter
- Run the following command to start the uninstall of Exchange Server 2019 -> .\Setup /Mode:Uninstall /IAcceptExchangeServerLicenseTerms_DiagnosticDataOn
With the above command, I turned on Diagnostic Data, you can change the “On” to “Off” at the end of the command. This should start what looks like an installation however our Mode is set to “Uninstall”.
Once the setup runs for a few minutes, it errors out as shown below:
Troubleshooting:
In this section, we used the following tools/commands to get to the bottom of the issue:
- PowerShell – Exchange commands
- PowerShell – Get all services running
- Regedit – Check roles for watermarks and actions
The error message makes no sense as the Server in question was showing fine in PowerShell and the Exchange Admin Center, however when checking on the command “Get-RpcClientAccess -Server “ServerName”, it gave an error as shown below:
Upon checking the state of the Exchange Server Services, it was noted that we were also missing some as shown below, we achieved this running the command from the server directly:- “Get-Service *Exchange*”:
The next place we can check on with regards to our troubleshooting is the Registry. You may have seen when an installation of Exchange, whether it is Exchange 2013, 2016 or 2019, you have the following items under each role that is failing to install/uninstall:
- Action
- Watermark
In the Figure below, I have highlighted the path to where you can find these Watermarks and Actions:
Resolution:
In our scenario, we had a Watermark and Action under the ClientAccessRole, CafeRole, HubTransport and TransportRole.
You can right click the Action and Watermark item highlighted in the image above and delete them, it has no effect on anything but the install/uninstall.
Once you have gone through the roles affected and removed the items, you can close out the Registry and then re-run the uninstall. This time it should succeed and complete.