XenApp / XenDesktop DB creation with locked SQL servers

The following lines of code create the SQL scripts for the database creation and the assignment of one controller to the site. Give the scripts to your database admins afterwards.

In any enterprise environment I recommend to separate the Site-, Logging- and Configuration database from each other.

This leads to three pairs of scripts:

Create Site Database script

Get-XDDatabaseSchema -SiteName SITENAME -DataStore Site -DatabaseName DBNAME -DatabaseServer DBSERVERNAME -ScriptType FullDatabase > c:\prep\dev_create_site_script.sql

 

Add Controller

Get-XDDatabaseSchema -AdminAddress CONTROLLERNAME-SiteName SITENAME -DataStore Site -DatabaseName DBNAME-DatabaseServer DBSERVERNAME -ScriptType AddController > C:\prep\dev_add_controller_site_script.sql

 

Create Logging Database script

Get-XDDatabaseSchema -SiteName SITENAME -DataStore Logging -DatabaseName DBNAME -DatabaseServer DBSERVERNAME -ScriptType FullDatabase > c:\prep\dev_create_logging_script.sql

 

Add Controller

Get-XDDatabaseSchema -AdminAddress CONTROLLERNAME-SiteName SITENAME -DataStore Logging -DatabaseName DBNAME-DatabaseServer DBSERVERNAME -ScriptType AddController > C:\prep\dev_add_controller_logging_script.sql

 

Create Monitoring Database script

Get-XDDatabaseSchema -SiteName SITENAME -DataStore Monitor -DatabaseName DBNAME -DatabaseServer DBSERVERNAME -ScriptType FullDatabase > c:\prep\dev_create_monitor_script.sql

 

Add Controller

Get-XDDatabaseSchema -AdminAddress CONTROLLERNAME-SiteName SITENAME -DataStore Monitor -DatabaseName DBNAME-DatabaseServer DBSERVERNAME -ScriptType AddController > C:\prep\dev_add_controller_monitor_script.sql

Please be aware of the fact that the following prerequisites must be met:

The databases need a special collation: Latin1_General_CI_AS_KS. You can run “ALTER DATABASE

[…] COLLATE Latin1_General_CI_AS_KS” before running any of the scripts.

The scripts need to be run in sqlcmd-mode

Have fun with your database admins, they will love you 😉

If there are no further restrictions in security and you are having access to a non-locked SQL server have a look at this Citrix blog post regarding automated site creation: http://blogs.citrix.com/2013/10/02/xendesktop-7-site-creation-via-powershell/