A while ago I did a post about updating connection strings for mirroring. Since then, I’ve had other requests for connection string manipulations. So I’m going to pull them into one post with an update for 7.6, Availability Groups and script updates.
XenDesktop 7.6
XenDesktop 7.6 introduced the Analytics Service which also needs its db connection string updating. The service is responsible for sending information back to Citrix as part of CEIP.
The only change to the commands in the previous blog is the need to also use the cmdlet:
Set-AnalyticsDBConnection
to update the dbconnection. If you run it just after you use:
Set-SfDBConnection
then it should update correctly.
Always On Availability Groups
Many customers have started to use Always On Availability Groups for their HA database solution. For the most part the use of Availability Groups is invisible to XenDesktop. However, there is one recommended setting that Microsoft say should be part of the connection string, MultiSubnetFailover=true. The option is recommended in both single subnet and multi-subnet environments, and it speeds up recovery when a HA event occurs.
This option is only available in .Net versions which have been patched to include it. Depending on the version of XenDesktop you’re using will depend on which KB patch you’ll need to add support.
.Net 3.5 SP1, patch with this KB: http://support.microsoft.com/kb/2654347
.Net 4.0, update to at least 4.0.2, but 4.0.3 is recommended: http://support.microsoft.com/kb/2600211
.Net 4.5, nothing to patch, support was built into this .Net version.
Once you’re running on a supported .Net version, you’ll need to update the connection strings. To do this is very similar to the changes for mirroring, you have to null the connection string, then set it back to the same, but with extra option “;MultiSubnetFailover=true”.
Keyword not supported: ‘multisubnetfailover’
On Windows 7 or 2008 R2, you may receive the above error message on the Configuration node of studio. This is because Studio uses the MMC which will be using .Net 3.5 SP1 runtime on Windows 7 and 2008 R2. To avoid the error you need to apply the patch .Net 3.5 SP1. Note the services will be using the .Net 4.x runtime. (This section was added on April 15th 2015)
Updated Script
I’ve also updated the script since the previous post to include the analytics service. While doing so I also broke out the core functions into their own file, and created some wrapper scripts to use those functions. The new scripts are bundled into a .zip:
https://citrix.sharefile.com/d/sc237fc7d5ed4f0fb
The scripts need powershell v3 at the moment (I may turn part of it into a module, and might be able to switch to powershell v2, but v3 is needed to load the core script into the other scripts.)
The scripts have been tested on Server 2012 R2, with XenDesktop 7.5 and XenDesktop 7.6. Note that this was as a full site admin and in local admin powershell window.
The provided scripts are:
DBConnectionStringFuncs.ps1 – this is the core script, and does the actual work. It contains common functions which the following scripts then use.
Change_XD_Failover_Partner_v1.ps1 – this is similar to the previous script I posted, and is used to update the failover partner.
Change_XD_To_ConnectionString.ps1 – this takes passed in connection strings and uses them, so a very generic version.
Change_XD_To_MultiSubnetFailover.ps1 – this toggles the addition and removal of MultiSubnetFailover=true. IE run it once and the option is added, run it again and the options is removed.
Change_XD_To_Null.ps1 – this is a reset of all the connection strings on the localhost as something has gone wrong. Note because this resets the connection strings to null, it will actually place the ddc into a “initial” state. IE if you run studio it’ll ask if you want to create a site, or join to another ddc. This is useful is something has gone wrong somewhere, and a reset is needed, as you can then attempt to set the connection strings again.
If you need to do some kind of connection string manipulation feel free to look at how the Change_XD scripts use the functions in DBConnectionStringFuncs.ps1.
A Disclaimer Applies to the Scripts:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.