Remove orphaned Delivery Controller from XenApp XenDesktop Site

Remove orphaned, deleted, failed Delivery Controller from a XenApp or XenDesktop site.

If one of your Delivery Controllers has completely failed and you deleted it’s computer object from Active Directory, you may then attempt to gracefully remove the Delivery Controller via Citrix Studio however it will fail. This happens because the SQL stored procedure fails to generate a necessary part of the T-SQL script which removes all references of the Controller from the database. Instead, you must run a manual eviction script to complete the removal.

To show you what happens, I’ve build a Delivery Controller (, added to my existing Citrix site. Next I deleted the virtual machine and computer object from Active Directory. When I launch Studio, to perform a graceful remove navigate to Configuration -> Controllers. Click -> Remove Delivery Controller.

Click Yes.

Click Yes.

You will receive the below unexpected error. Click View details.

The details pane shows information we expect to see such as ActiveDirectoryObjectNotFoundException.

From a healthy Delivery Controller, launch PowerShell and run commands asnp citrix.* & Get-BrokerController -DNSName yourcontrollername

What you are interested in here is the SID of the orphaned controller. Take a copy of the SID. This SID will be referenced in the eviction script we run next.

Create a PowerShell script by copying the following lines, changing $DBName and $EvictedSID values to your database name and orphaned controller name.

The script should be imported to a PowerShell script.

Launch PowerShell from a Delivery Controller, load the Citrix snapins and then run the eviction script.

An evict_.txt script will be created in your user profile folder %userprofile%. Open the text file.

The text file contains a SQL script which now must be run against the site database. Copy the file to your SQL server.

Paste the script in to a SQL Query and then execute. You should receive notification that the controller has been removed from the Citrix site. If you receive any messages about failing to remove services from the controller, run the relevant SQL stored procedure to remove the service references manually.

Now when browsing Citrix Studio, the controller no longer appears.


Leave a Reply