@XDtipster - Removing controllers from a website using XD POSH

10:53 PM
@XDtipster - Removing controllers from a website using XD POSH -

Knowing how to completely remove the controller from a site using POSH is something that can come in handy that time. What your'e trying to remove a failed controller or orphans receive an exception Studio while or if you just like to do things manually the end result should be the same ie a better understanding of architecture XenDesktop ....

Before I continue, I must stress that there is a tool called XenDesktop Checker site that can be used to automate much of what I am about to cover, but many ways than taking the easy route especially for those looking to get a better understanding of the architecture and XD how things together. XD Site Checker is supported only with XD5.x.

So go, to successfully remove a controller from a site that we basically need to remove all traces of service instances of the aforementioned controllers (Broker, Configuration, Host, MCS etc. ...) from the DB site so that when we run the Get-ConfigRegisteredSericeInstance cmdlet to query all service instances recorded in the website, we only see references to running service instances on the rest active Controllers

is an example of what you might see when using POSH to check all service instances of being registered Broker running in a site :.

Click on screenshot to see the picture:

In capturing screen above, we can see that a number of Broker instances running on two separate controllers (DC1 and DC2) are currently registered with the configuration service for XD site. At this point, you might ask yourself the following question:

"I thought there was only one Broker instance running on each controller?"

Well, this is indeed the case, but what you are seeing above is a reference to all interfaces that the service instances support. We'll talk again interfaces but for now just think of them as entry points to engage the service instance. For example, all services have a defined SDK interface that allows administrators to interact with the service through Studio POSH

Note :. You can view the interface types available via POSH for the Broker via the following cmdlet:

Get-BrokerServiceInstance

now that we know the end goal, we will work through a basic scenario ...

ENV

Site Name: training

DataBase Name: CitrixTraining

Controllers: DC1.training.lab, DC2.training.lab

Action

manually remove active controller DC2 .training.lab from the site using POSH

SOLUTION:

Step 1 :

a POSH dc1.training.lab window or from a mgmt workstation, log DB dc2.training.lab site using the following simple script:

XD7.x

Set-ConfigDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-BrokerDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set -ProvDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-AcctDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set- HypDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-EnvTestDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-MonitorDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set -SfDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-LogDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-AdminDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-AnalyticsDBConnection -DBConnection $ null -AdminAddress dc2.training.lab ( XD 7.6 ONLY )

XD5.x

Set-ConfigDBConnection - DBConnection $ null -AdminAddress dc2.training.lab
Set- BrokerDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-HypDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-ProvDBConnection -DBConnection $ null -AdminAddress dc2.training.lab
Set -PvsvmDBCconnection -DBConnection $ null -AdminAddress dc2.training.lab
Set-AcctDBConnection -DBConnection $ null -AdminAddress dc2.training.lab


Step 2

now dc2.training.lab is offline Site DB consided the controller is to be in a OFF state.

Run Get-BrokerController -AdminAddress dc1.training.lab in the same POSH window to view the current status and take note of SID (green) value in the screenshot below, because it is needed in step 3:

Click on screenshot to see the picture:

notes : Although dc2.training.lab is disabled and does not take an active part in running the site at this stage, it is still very much part of the site and if return to an active state, will resume his responsibilities as a working controller.

Step 3

Using the SID value from step 2, generate a removal script for each running service instances on dc2.training.lab. To do this, run the following simple script on dc1.training.lab:

XD7.x

Get-BrokerDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21- 872651969-1959181362-2982015048-1126> c: brokerevict.sql
Get-ConfigDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: configevict.sql
Get-HypDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: hostevict.sql
Get-ProvDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: provevict.sql
Get-AcctDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048- 1126> c: adevict.sql
Get-EnvtestDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: envtestevict.sql
Get-LogDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: logevict.sql
Get-MonitorDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5 21-872651969-1959181362-2982015048-1126> c: monitorevict.sql
Get-sfDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: Sfevict .sql
Get-AdminDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: adminevict.sql
Get-AnalyticsDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: analyticsevict.sql ( XD 7.6 ONLY )

XD5.x

Get-BrokerDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: brokerevict.sql
Get-ConfigDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1 -5-21-872651969-1959181362-2982015048-1126> c: configevict.sql
Get-HypDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c : hostevict.sql
Get-ProvDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: provevict.sql
Get-PvsvmDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969-1959181362-2982015048-1126> c: pvsvmevict.sql
Get-AcctDBSchema -databasename CitrixTraining -ScriptType evict -sid S-1-5-21-872651969 -1959181362-2982015048-1126> c: adevict.sql

step 4

Perform the expulsion scripts generated in step 3 above in SQLCMD [1945005mode] against the DB website (CitrixTraining). This will achieve the following:

1. All running service instances on dc2.training.lab will be removed from the site

2. Database User [TRAININGDC2$] to the controller will be deleted dc2.training.lab

Step 5

Run Get-BrokerController -AdminAddress dc1. training.lab again and check that dc2.training.lab is listed as a site controller

Click on screenshot to see the picture:

Step 6

as a final action, we need to clean the registry service site configuration by removing all instances of dc2.training.lab services

. To go back and sort the contents of the tables and ServiceAccount ServiceInstanceUid use the following results cords and hoses in a text file:

Get-ConfigRegisteredServiceInstance | select ServiceAccount, serviceinstanceuid | tri-object -property ServiceAccount> c: registeredinstances.txt

Once you exit, you can use an advanced text editor like Notepad ++ is to select ServiceInstanceUid for service instances on DC2 .training.lab and use the data to build and run a simple script unsubscribe:

unregister-ConfigRegisteredServiceInstance -serviceinstanceuid eb73450b-732f-461d-bf34-fcf7608fa6
unregister- ConfigRegisteredServiceInstance -serviceinstanceuid 19d6252a-db74-4b34 -adfd-bd025094ab4
Unregister-ConfigRegisteredServiceInstance -serviceinstanceuid afef3dc6-13ba-496th-A26A-ff3d8efa305c
Unregister-ConfigRegisteredServiceInstance -serviceinstanceuid 4a21561d-e2d9-4cd3-9b9d-fd07db7e02
Unregister -ConfigRegisteredServiceInstance -serviceinstanceuid 79b9edcb-3aa5- 4a9c-a75b-c38f7403f7ee
Unregister-ConfigRegisteredServiceInstance -serviceinstanceuid a5ee5a66-6f7b-4f8b-a9c8-d45e00c13dfd
Unregister-ConfigRegisteredServiceInstance -serviceinstanceuid ............ ........................
Unregister-ConfigRegisteredServiceInstance -serviceinstanceuid .................. ..................

After the script, execute Get-ConfigRegisteredServiceInstance | select ServiceAccount, serviceinstanceuid | tri-object -property ServiceAccount and you should notice that all dc2.training.lab for service instances have been removed from the site of the Registry Configuration Service.

And that's about all. Six steps to gracefully remove a straighforward Controller DB and cleaning the site using POSH.

Although we have a simple user interface option to do this in Desktop / Citrix Studio I think it's important to know how to do by POSH for the rare ocasion when this interface option user fails.

Best regards
Mick Glover (aka Tipster XD)
Senior Specialist preparation
Worldwide support [EMEA]
Citrix Systems, Inc.
Follow @xdtipster

Previous
Next Post »

1 comment

  1. Information given in this blog is really very informative and i am really grateful that you shared this. Thank you so much for your support.


    Prohut

    ReplyDelete