To demonstrate how to build an evict script from scratch using PoSH SDK in order to remove a Delivery Controller from the database.
Depending on your XenApp &XenDesktop version, the number of services might change, consequently, the number of tables and data wrote to the database. That's why it is important to build the evict script for each specific use case.
The script should be built from a working DDC.
Launch a PowerShell prompt and add Citrix modules (asnp Citrix*).
To obtain the failed DDC SID on the database, run the following command:
Get-BrokerController
It should return the list of controllers for the site and the state of each one of them.
It’s important to run this command to obtain the controller SID because we need the SID registered on the db, not the one on AD since it might be slightly different if the account has been removed and recreated, or changed the SID in any other way.
Notice that the failed Controller State is “OFF”.
In order to know which database schemas do you need to clean on the database, run the following command:
Get-Command Get*DBSchema
For 7.16 it will return:
Open a PowerShell ISE as an administrator and paste all the commands.
For each DBSchema command, you can configure the same parameters, meaning that the syntax will work for all of them.
According to the latest PoSH SDK documentation available, the minimum required parameters to build an Evict script are:
So the parameters for each service DBSchema should look like:
Get-LogDBSchema –DatabaseName “MySiteDB” –ScriptType Evict –SID “Controller to evict SID”
Also for Monitor and Logging schema, you can remove the data on the Site DataStore by using the following commands:
Get-LogDBSchema -DataStore Logging –DatabaseName “MyLoggingDB” –ScriptType Evict –SID “Controller to evict SID”
Get-MonitorDBSchema -DataStore Monitor -DatabaseName "MyMonitorDB” –ScriptType Evict –SID “Controller to evict SID”
So the script should look like:
Once you run it, go to the path and you will find the Evict.sql file generated which is a SQL script that can be run either on the SQLCMD or the Management Studio in SQLCMD mode.
Citrix Developer Documentation - XenApp and XenDesktop SDK