How to manually uninstall and remove a corrupted Citrix MPS (4) server from a Farm.

citrix-logo[2] Came across a server which due to circumstances was unable to start the IMA service. (starting the IMA service would just crash the IMA process)
I toyed with the system for a while but since the server needed to be reinstalled anyway I needed to uninstall Citrix manually so here are the steps I took:

If you try to uninstall Citrix the classic way you are greeted with an error like:
"error 26515. unable to unregister…"

If so, try the following command:

msiexec /x CITRIXINSTALLER.msi CTX_MF_FORCE_SUBSYSTEM_UNINSTALL=YES
(or instead of the .msi you can use the GUID of your citrix installation)

After you’ve successfully removed the Citrix software, the server is still listed in the CMC. (Citrix Management Console) 
Removing the server from the farm through the CMC will give you this error:
Error: "The Citrix Management Console failed to remove the server. Error code 80000001."
or
Error: "The Citrix Management Console failed to remove the server. Error code 80000007."

You can resolve this error by using the following command (after backing up your Citrix Datastore of course!)

dscheck /full servers /deleteall SERVERHOSTNAME
If everything goes well, it will give similar output like this:
Data Store Validation Utility.    Version: 5.19

Disclaimer
Caution! This tool modifies the data in your database. Using this tool incorrect
ly can cause serious and irrecoverable problems with the data. Citrix cannot gua
rantee that problems resulting from the incorrect use of this tool can be solved
. Use this tool at your own risk and only as directed by Citrix support staff.

Would you like to continue [y/n] ? y

Using the /Clean option may result in changes being made to the Data Store.
Please be sure the Data Store has recently been backed up before continuing.

Would you like to continue [y/n] ? y
Server clean-up for <00000BDE>
MFServer <00000BDE> DelEntry result 0x0
MFServerReadOnlyObject <00000BDE> Sync result 0x0
MFServerReadOnlyObject <00000BDE> DelEntry result 0x0
Failed to find any MF Server Entries in the DS
User trust object <SERVERHOSTNAME> Sync result 0x0
User trust object <SERVERHOSTNAME> DelEntry result 0x0
LM Server object <SERVERHOSTNAME> DelEntry result 0x0
LBrowserM Server object <SERVERHOSTNAME> DelEntry result 0x0

Server clean-up for <0bde-000b-00eb2b22>

Entry clean-up for <SERVERHOSTNAME>
=============================================
The line marked in red signifies another problem. You can cure this by running dscheck again only now using the following parameters:
dscheck /full servers /clean

After that you should be able to reinstall the server without any problems.
I’ve found solutions to the problems I encountered but they were scattered across the Internet so I provided the information here in one article.
If this post helped you out, help me out keeping this site alive and visit some of my sponsors on the left or right.. Thanks..!
Tags:Citrix, error 26515, The Citrix Management Console failed to remove the server, Error code 80000007, Error code 80000001, DSCHECK