This article describes how to change the SQL connection strings configured on a XenApp/XenDesktop Delivery Controller to use custom port.
Delivery Controller is a collection of services, each of which has its own SQL connection string. To change the SQL connection strings, you use PowerShell to change each service. Some points to keep in mind:
Getting Started
Retrieve the existing Database connections
Run the following commands to see the existing database connection strings
## Load the Citrix snap-ins
asnp Citrix.*
## ## Get the current Delivery Controller database connections
Get-ConfigDBConnection
Get-AcctDBConnection
Get-AnalyticsDBConnection # 7.6 and newer
Get-AppLibDBConnection # 7.8 and newer
Get-OrchDBConnection # 7.11 and newer
Get-TrustDBConnection # 7.11 and newer
Get-HypDBConnection
Get-ProvDBConnection
Get-BrokerDBConnection
Get-EnvTestDBConnection
Get-SfDBConnection
Get-MonitorDBConnection
Get-MonitorDBConnection -DataStore Monitor
Get-LogDBConnection
Get-LogDBConnection -DataStore Logging
Get-AdminDBConnection
1. Run the following commands to verify connectivity to the database
Adjust the variables to match your desired connection string. For example, to add custom port to the connection strings, then set the $ServerName variable to "DBServername\Instance,CustomPortNumber".
asnp citrix.*
$ServerName = "<DBServername\Instance,CustomPortNumber>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$csSite = "Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True"
$csLogging = "Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True"
$csMonitoring = "Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True"
Test-AcctDBConnection -DBConnection $csSite
Test-AdminDBConnection -DBConnection $csSite
Test-AnalyticsDBConnection -DBConnection $csSite # 7.6 and newer
Test-AppLibDBConnection -DBConnection $csSite # 7.8 and newer
Test-BrokerDBConnection -DBConnection $csSite
Test-ConfigDBConnection -DBConnection $csSite
Test-EnvTestDBConnection -DBConnection $csSite
Test-HypDBConnection -DBConnection $csSite
Test-LogDBConnection -DBConnection $csSite
Test-LogDBConnection -DataStore Logging -DBConnection $csLogging
Test-MonitorDBConnection -DBConnection $csSite
Test-MonitorDBConnection -Datastore Monitor -DBConnection $csMonitoring
Test-OrchDBConnection -DBConnection $csSite # 7.11 and newer
Test-ProvDBConnection -DBConnection $csSite
Test-SfDBConnection -DBConnection $csSite
Test-TrustDBConnection -DBConnection $csSite # 7.11 and newer
Remove the existing Database connections
## Load the Citrix snap-ins
asnp Citrix.*
## ## Clear the current Delivery Controller database connections
## Note: AdminDBConnection must be the last command
Set-ConfigDBConnection -DBConnection $null
Set-AcctDBConnection -DBConnection $null
Set-AnalyticsDBConnection -DBConnection $null # 7.6 and newer
Set-AppLibDBConnection -DBConnection $null # 7.8 and newer
Set-OrchDBConnection -DBConnection $null # 7.11 and newer
Set-TrustDBConnection -DBConnection $null # 7.11 and newer
Set-HypDBConnection -DBConnection $null
Set-ProvDBConnection -DBConnection $null
Set-BrokerDBConnection -DBConnection $null
Set-EnvTestDBConnection -DBConnection $null
Set-SfDBConnection -DBConnection $null
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-AdminDBConnection -DBConnection $null -force
Get-Service Citrix* | Stop-Service -Force
Get-Service Citrix* | Start-Service
After restarting all the Citrix services, if you still see the errors, you must restart the server.
## Load the Citrix snap-ins
asnp Citrix.*
## ## Get the current Delivery Controller database connections
Get-ConfigDBConnection
Get-AcctDBConnection
Get-AnalyticsDBConnection # 7.6 and newer
Get-AppLibDBConnection # 7.8 and newer
Get-OrchDBConnection # 7.11 and newer
Get-TrustDBConnection # 7.11 and newer
Get-HypDBConnection
Get-ProvDBConnection
Get-BrokerDBConnection
Get-EnvTestDBConnection
Get-SfDBConnection
Get-MonitorDBConnection
Get-LogDBConnection
Get-AdminDBConnection
## Replace <dbserver> with the SQL server name,custom port and instance if present
## Replace <dbname> with the name of your restored Database
## Note: AdminDBConnection should be first
$ServerName = "<DBServername\Instance,CustomPortNumber>"
$SiteDBName = "<SiteDbName>"
$LogDBName = "<LoggingDbName>"
$MonitorDBName = "<MonitorDbName>"
$csSite = "Server=$ServerName;Initial Catalog=$SiteDBName;Integrated Security=True"
$csLogging = "Server=$ServerName;Initial Catalog=$LogDBName;Integrated Security=True"
$csMonitoring = "Server=$ServerName;Initial Catalog=$MonitorDBName;Integrated Security=True"
Set-AdminDBConnection -DBConnection $csSite
Set-ConfigDBConnection -DBConnection $csSite
Set-AcctDBConnection -DBConnection $csSite
Set-AnalyticsDBConnection -DBConnection $csSite # 7.6 and newer
Set-HypDBConnection -DBConnection $csSite
Set-ProvDBConnection -DBConnection $csSite
Set-AppLibDBConnection –DBConnection $csSite # 7.8 and newer
Set-OrchDBConnection –DBConnection $csSite # 7.11 and newer
Set-TrustDBConnection –DBConnection $csSite # 7.11 and newer
Set-BrokerDBConnection -DBConnection $csSite
Set-EnvTestDBConnection -DBConnection $csSite
Set-SfDBConnection -DBConnection $csSite
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $null
Set-LogDBConnection -DBConnection $null
Set-LogDBConnection -DBConnection $csSite
Set-LogDBConnection -DataStore Logging -DBConnection $csLogging
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
Set-MonitorDBConnection -DBConnection $null
Set-MonitorDBConnection -DBConnection $csSite
Set-MonitorDBConnection -DataStore Monitor -DBConnection $csMonitoring
Note: It is important to verify that all the preceding Set-<service>DBConnection commands have returned a result of OK. If the result is other than OK for any of these commands, it might be necessary to enable logging or tracing to determine the cause of the connection failure.
Note: The Set-LogDBConnection -DBConnection $null and Set-MonitorDBConnection -DBConnection $null will return DBUnconfigured instead of OK.
This article explains how to modify the SQL connection strings on a XenApp/XenDesktop Delivery Controller so that the SQL database connection uses a custom port instead of the default SQL port.
How to use PowerShell to Change XenDesktop SQL Connection String
https://support.citrix.com/article/CTX140319
How to Disable or Enable Configuration Logging Service in XenDesktop 7 using PowerShell