STOP!!! This AWESOME Blog post has been updated and can be found here

The following steps which i’d like to share with everyone are the result of a query I received from a partner at a recent training event. For Disaster Recovery purposes the partner wanted to know how to join a new controller to a site DB when there are no active controllers to facilitate the process. Faced with this query I looked into the process and it turned out to be quite simple…

Environment Details:
SQL server = sqlserver.training.lab
XenDesktop DB name = CitrixXenDesktopDB
New Controller = dc2.training.lab

Step 1: Create an instance Script for each service running on the new Controller (dc2.training.lab) and execute against the XD database (as usual, query’s must be run in SQLCMD mode):

XD5

Get-BrokerDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\brokerjoin.sql
Get-ConfigDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\configjoin.sql
Get-HypDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\hostjoin.sql
Get-ProvDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\provjoin.sql
Get-PvsVmDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\pvsvmjoin.sql
Get-AcctDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\adjoin.sql

XD7

Get-BrokerDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\brokerjoin.sql
Get-ConfigDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\configjoin.sql
Get-HypDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\hostjoin.sql
Get-ProvDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\provjoin.sql
Get-AcctDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\adjoin.sql
Get-AdminDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\adminjoin.sql
Get-LogDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\logjoin.sql
Get-EnvTestDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\envtestjoin.sql
Get-MonitorDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\monitorjoin.sql
Get-SfDBSchema -DatabaseName CitrixXenDesktopDB -ScriptType instance > c:\sfjoin.sql

Step 2: Set the DB connection string for each of the new controller services:

XD5

Set-BrokerDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security =True”
Set-ConfigDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-HypDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-ProvDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-PvsVmDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security =True”
Set-AcctDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”

XD7

Set-AdminDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security =True”
Set-BrokerDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security =True”
Set-ConfigDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-HypDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-ProvDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-AcctDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-EnvTestDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security =True”
Set-MonitorDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-SfDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”
Set-LogDBConnection -DBConnection “Server=sqlserver.training.lab;Initial Catalog = CitrixXenDesktopDB; Integrated Security = True”

Notes:
-If using XD7, The delegated administration service (alias=admin) must be the first service you set the DB connection string for. If not then all other strings above will fail/Timeout. This is expected behaviour.
-Force switch was introduced in XD7.1 and can be used to force the DBConnection strings even if the DBConnection for the delegated administration service has not been set. Using the -force switch allows you to order the services in the script above any way you like.

Step 3: Register the new controllers service instances with the existing site Configuration Service:

XD5

Get-BrokerServiceInstance | Register-ConfigServiceInstance
Get-ConfigServiceInstance | Register-ConfigServiceInstance
Get-HypServiceInstance | Register-ConfigServiceInstance
Get-ProvServiceInstance | Register-ConfigServiceInstance
Get-PvsVmServiceInstance | Register-ConfigServiceInstance
Get-AcctServiceInstance | Register-ConfigServiceInstance

XD7

Get-BrokerServiceInstance | Register-ConfigServiceInstance
Get-ConfigServiceInstance | Register-ConfigServiceInstance
Get-HypServiceInstance | Register-ConfigServiceInstance
Get-ProvServiceInstance | Register-ConfigServiceInstance
Get-AcctServiceInstance | Register-ConfigServiceInstance
Get-AdminServiceInstance | Register-ConfigServiceInstance
Get-LogServiceInstance | Register-ConfigServiceInstance
Get-EnvTestServiceInstance | Register-ConfigServiceInstance
Get-MonitorServiceInstance | Register-ConfigServiceInstance
Get-SfServiceInstance | Register-ConfigServiceInstance

If anyone has any questions or is having any problems following the steps above let me know in the comments section below.

Best Regards
Mick Glover (aka XD Tipster)
Senior Readiness Specialist, Worldwide Support Readiness [EMEA]
Citrix Systems, Inc.