To explain how to build a simple script to change the connection strings for FMA services on a site after changing from a single SQL server to SQL mirroring or SQL HA.
This should be performed only on one controller at the time.
We will start assuming that the database have already been migrated and all the logins and roles are also created on the newly added SQL partner or new SQL server.
Stop Configuration logging:
Set-LogSite –State DisabledStop Monitor data collection:
Set-MonitorConfiguration –DataCollectionEnabled $FalseBackup the registry:
Since connection strings are stored on the registry, it’s important to have a backup if something goes wrong so you can go back to the original state.Confirm the current connection strings:
Depending on the version of XenApp & XenDesktop 7.x we will have more or less services, then connection strings. That being said, the first thing that we need to know is how many database strings I have to update. In PowerShell run the following command to confirm the current connection strings:Get-Command Get*DBConnection
For 7.16 It returns the following:
Highlight the commands and then hit enter to copy them to clipboard.
Paste on the PowerShell window and you should receive something like:
Tip: If the command fails, check that all services are up and running.
In here we are going to start building a little script that will help us nullifying the connection strings and then to set the new ones.
Run the following command to obtain the ‘Set’ commands for the db strings:
Get-Command Set*DBConnection
For 7.16 It returns the following:
Open PowerShell ISE as an admin and show the script pane (Ctrl + R). Write the following:
asnp Citrix*
$dbString = $null
Set-AnalyticsDBConnection -DBConnection $dbString
Set-AppLibDBConnection -DBConnection $dbString
Set-BrokerDBConnection -DBConnection $dbString
Set-ConfigDBConnection -DBConnection $dbString
Set-EnvTestDBConnection -DBConnection $dbString
Set-HypDBConnection -DBConnection $dbString
Set-LogDBConnection -DBConnection $dbString
Set-MonitorDBConnection -DBConnection $dbString
Set-OrchDBConnection -DBConnection $dbString
Set-ProvDBConnection -DBConnection $dbString
Set-SfDBConnection -DBConnection $dbString
Set-TrustDBConnection -DBConnection $dbString
Set-AcctDBConnection -DBConnection $dbString #Important
Set-AdminDBConnection -DBConnection $dbString #Important
Before running the script please make sure that Citrix AD Identity Service (Acct) and Citrix Delegated Admin Service (admin) are the final ones, if they are changed before the other ones you can run into issues like “There was an error communicating with the Citrix Delegated Admin Service” which will require to apply the registry backup obtained before and run the script again in the right way.
Once you run the script you can confirm with step 4) if all the connections are nulled.
Tip: If you face issues trying to nullify the connection strings, try using –Force on each command.
6. Set the new connection strings:
If everything went right, now we should be able to test the services by running the following command on PowerShell:
Get-Command Get*serviceStatus
On 7.16 it returns the following services:
Highlight the commands and then hit enter to copy them to clipboard.
Paste on the PowerShell window and every service status should be OK.
Run the following commands to check if your DataStores have been automatically configured:
Get-MonitorDataStore
Get-LogDataStore
If they don’t return both connection strings you might set the DataStore manually, but before doing that, try restarting both services or if possible the controller.
If still not there, try with the following commands:
Set-MonitorDBConnection –DataStore Monitor –DBConnection “SQL connection string pointing to monitor db”
Set-LogDBConnection –DataStore Logging –DBConnection “SQL connection string pointing to Logging DB”
To enable monitor service to start collecting data again run the following command:
Set-MonitorConfiguration –DataCollectionEnabled $true