Tuesday, November 29, 2011

How to remove XenDesktop DDC5 gracefully from the XD5 farm

In my previous blog I mention hard way to remove stale DDC from XD database.

Launch the Desktop Studio and highlight controllers as shown below. Select the controller you want to remove and choose "Remove Controller"

image

This will prompt for action to update Database . Choose "NO " here image

This will prompt for generating SQL script which needs to be run on SQL server database

image

Script looks like this . Copy this script

image

And then choose DDC database on SQL manager . Right click and select new script . Paste  it from previous step and run "Execute"

image

Once the script is ran then it will give following message

image

Once Desktop Studio is update , controller will be removed

image

Run powershell command Get-BrokerController and confirm that other controller is out completely.

image

Friday, November 18, 2011

How to remove stale DDC from XenDesktop 5 Farm

Stale DDC inside XenDesk 5 Farm may get created because of various reason and this does not get removed unless database is cleaned.

1. If you run Get-brokercontroller from PS console of Desktop Studio then you see the stale entry. Below two stale entry for SID

S-1-5-21-1757981266-413027322-725345543-64627 and  other one ending with 64712image 

2. Same thing will be shown via Desktop Studio

 image

3. Following script needs to be run in same order from desktop studio PS console with XD database name

Get-ConfigDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid > EvictDDC.sql  (Here we are creating EvictDDC.sql)
Get-AcctDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql(Here we are appending to  EvictDDC.sql)
Get-HypDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql
Get-ProvDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql
Get-PvsVmDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql
Get-BrokerDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql

4. This is how Script needs to be run in following order . First SID variable needs to be set and then rest of the commands need to be run. Here we are creating EvictDDC.sql file which is nothing but a stored procedure

image

5.  This file can be found under following

image

6. Now when we open this file with notepad  following entry can be found.

image 

7.   Open SQL server management studio and select the database and then open new script. Select the content from EvictDDC.sql  and paste as shown. Execute as shown below

image

8.   Last command Get-BrokerDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql  need to run as follows.

image

9.  Sometime Get-BrokerDBSchema -DatabaseName <XD database name> -ScriptType Evict -SID $sid >> EvictDDC.sql will fail with following message. Create new store procedure using working XD SID and then replace host name and SID with non working SID.

image

10.  Once all the above store procedure ran it will remove the stale entry from DDC

image

Even Desktop Studio will update the entry

 image