Quantcast
Channel: citrix – JGSpiers.com
Viewing all articles
Browse latest Browse all 163

Remove orphaned Delivery Controller from XenApp XenDesktop Site

$
0
0

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 (SF.jgspiers.com), 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 SF.jgspiers.com -> 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.

$DBName = "CitrixJGSPIERSSite"
$EvictedSID = "S-1-5-21-2782560517-345375582-3206342791-1196"

#
# Generate Database 'Evict' Scripts for XenDesktop DataStore
#
#
Get-ConfigServiceStatus

Get-LogSite 

Get-BrokerController   -Filter {(SID -eq $EvictedSID)} -MaxRecordCount 2147483647

Add-Content "$PWD\evict_$sid.txt" (Get-AcctDBSchema  -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-HypDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-ProvDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-BrokerDBSchema -DatabaseName $DBName -ScriptType 'Evict' -SID $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-MonitorDBSchema -DatabaseName $DBName -DataStore 'Site' -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-SfDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-EnvTestDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-ConfigDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-LogDBSchema -DatabaseName $DBName -DataStore 'Site' -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-AdminDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

Add-Content "$PWD\evict_$sid.txt" (Get-AnalyticsDBSchema -DatabaseName $DBName -ScriptType 'Evict' -Sid $EvictedSID)

# Script completed successfully

# Generate Database 'Evict' Scripts for 'Logging' DataStore

#
#
Get-ConfigServiceStatus 

Get-LogSite 

Get-BrokerController   -Filter {(SID -eq $EvictedSID)} -MaxRecordCount 2147483647

Add-Content "$PWD\evict_$sid.txt" (Get-LogDBSchema -DatabaseName $DBName -DataStore 'Logging' -ScriptType 'Evict' -Sid $EvictedSID)

# Script completed successfully

# Generate Database 'Evict' Scripts for 'Monitor' DataStore

#
#
Get-ConfigServiceStatus 

Get-LogSite 

Get-BrokerController   -Filter {(SID -eq $EvictedSID)} -MaxRecordCount 2147483647

Add-Content "$PWD\evict_$sid.txt" (Get-MonitorDBSchema -DatabaseName $DBName -DataStore 'Monitor' -ScriptType 'Evict' -Sid $EvictedSID)

# Script completed successfully

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.


Viewing all articles
Browse latest Browse all 163

Trending Articles