Unable to Remove XenDesktop Delivery Controllers from the XenDesktop Site

Unable to Remove XenDesktop Delivery Controllers from the XenDesktop Site

book

Article ID: CTX139505

calendar_today

Updated On:

Description

XenDesktop 7.x Delivery Controllers cannot be removed in Desktop Studio.

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Resolution

Complete the steps to remove the orphaned Delivery Controller (Controller) from a XenDesktop 7.x site:

  1. Run the Get-BrokerController command from PowerShell to get the SID of the orphaned Controller.

    User-added image

  2. Execute the following PowerShell script, replacing the XenDesktopDatabase with your XenDesktop database and the DCSID with your SID of the Controller you want to remove:

asnp Citrix*
$DBName = "XenDesktopDatabase"
$EvictedSID = "DCSID"

#
# 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)

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

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

Add-Content "$PWD\evict_$sid.txt" (Get-OrchDBSchema -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

After running the script, the evict.txt file is created under the users profile. The file could also be generated under C:\Windows\system32, if ran in IDE PowerShell as administrator.  The file contains a script required to run on the SQL server.


Problem Cause

The XenDesktop 7.x Delivery Controllers had been removed from Active Directory (AD) before they were removed from the XenDesktop site. The Controller removal process makes use of stored procedures that require a valid domain SID to generate the Transact-SQL (T-SQL) eviction script.

When a Controller is removed from AD before attempting to remove it from Studio, the stored procedure fails to generate the necessary part of the T-SQL script that removes the references to the Controller.

Issue/Introduction

XenDesktop 7.x Delivery ​Controllers cannot be removed in Desktop Studio.