This post has already been read 48359 times!
This article will show you how to remove a delivery controller from your environment that is no longer required or functioning. Attempts to re add the controller fail with the same machine name. You do not have access to SQL but you can hand over eviction scripts to your DBA to clean up your Xenapp database. This procedure worked in my Xenapp 7.x environment with a working Delivery Controller left in my Site. OBTAIN CONTROLLER SID NULL CONNECTIONS RUN EVICTION SCRIPTS EXECUTE SCRIPTS ON SQL CLEAN UP REGISTERED SERVICE INSTANCES RE-ADD DELIVERY CONTROLLER
Example 1 Obtain Controller SID Launch Powershell as an administrator on your remaining Delivery Controller.
Run Get-BrokerControllerTake note of the SID of the Delivery Controller that is no longer functioning.You will need this SID. The state may still show as Active if connections are still active.
Null Connections Now run the following to null connections to the controller you wish to remove from your Xenapp database. This is carried out on a working Delivery Controller. Set-ConfigDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-BrokerDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-ProvDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-AcctDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-HypDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-EnvTestDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-MonitorDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-SfDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-LogDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-AdminDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM Set-AnalyticsDBConnection -DBConnection $null -AdminAddress DDC02.TSCLAB.COM (XD 7.6 ONLY)
Get-BrokerController will now show the state of the second DDC as Off.
Run Eviction Scripts Next we need to run the following powershell script using the SID identified on the controller that you are going to remove These commands will generate eviction scripts. Take care to point the site, monitoring and logging parts to your correct database. Get-BrokerDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\brokerevict.sql Get-ConfigDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\configevict.sql Get-HypDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\hostevict.sql Get-ProvDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\provevict.sql Get-AcctDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\adevict.sql Get-EnvtestDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\envtestevict.sql Get-LogDBSchema -DatabaseName CITXENLOGDB -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\logevict.sql Get-MonitorDBSchema -DatabaseName CITXENMONDB -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\monitorevict.sql Get-sfDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\Sfevict.sql Get-AdminDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\adminevict.sql Get-AnalyticsDBSchema -DatabaseName CITXENSITE -ScriptType evict -sid S-1-5-21-40836310-432886117-331853842-1171 > c:\analyticsevict.sql (XD 7.6 ONLY)
Execute Scripts on SQL The above script will generate eviction scripts to run on SQL. Scripts appear locally on your delivery controller C drive.
Copy these over to your SQL server acting as Principal.
Execute the eviction scripts on the sql server in SQLCMD mode Open Sql Studio and click OPEN/FILE and choose your .sql script.![]()
Your script will be imported into SQL.
Run your query in SQL CMD MODE.Then click !Execute
You should get a result similar to the below.Repeat this procedure for all your eviction scripts that you created.
Run Get-BrokerController. You should only see your remaining Delivery Controllers in your environment.
Clean up Registered Service Instances Once this is done you need to clean up the registered service instances. You can see the controllers assigned to the services by running the below command. Get-ConfigRegisteredServiceInstance You will see that the faulty delivery controller is still registered to services. Run the following in your powershell window. Get-ConfigRegisteredServiceInstance | select serviceaccount, serviceinstanceuid | sort-object -property serviceaccount > c:\registeredinstances.txt This will generate a text file on c:\registeredinstances.txt.
Inside this file you will see something similar to the below: In this example we can see DDC01 and DDC02 are registered.
Once you have the output, you can use an advanced text editor like Notepad++ to select the ServiceInstanceUid’s for the service instances on ddc02 and use the data to build and run a simple unregister script:
Copy your amended text and create a .ps1 file on your local C drive of the Delivery Controller.Run the file within your administrative powershell cmd window. Once complete check the registered service instances once again.
You should not see any registered service instances on the delivery controller you have removed. You should now be able to add your Delivery Controller back in to the environment. Voila!