How-to create initial XenDesktop 7 site using PowerShell

Timm Brochhaus's picture

In my last blog post I wrote about how to create the Citrix XenDesktop 7 databases using PowerShell.

After some more tests today I am now able to create the initial XenDesktop 7 site configuration using PowerShell. The Citrix PowerShell cmdlet I used is New-XDSite.

Here is my PowerShell code to automatically create the initial XenDesktop 7 site configuration:

First of all I defined a couple of PowerShell variables again.

Remember: I decided to create three databases in my test environment (one for the site configuration,
one for the configuration logging information and one additional for the monitoring database). 

These three databases are used in the following PowerShell code.

 $DatabaseServer = ""
 $DatabaseName_Site = "XD7-DB_Site"
 $DatabaseName_Logging = "XD7-DB_Logging"
 $DatabaseName_Monitor = "XD7-DB_Monitor"

Now I can load the Citrix XenDesktop PowerShell Snapins and execute the New-XDSite cmdlet to create the site configuration within the previously created databases on the Microsoft SQL server.

 Add-PSSnapin Citrix.*
 New-XDSite -AdminAddress $env:COMPUTERNAME -SiteName $XD7Site -DatabaseServer $DatabaseServer -LoggingDatabaseName $DatabaseName_Logging -MonitorDatabaseName $DatabaseName_Monitor -SiteDatabaseName $DatabaseName_Site

After executing this PowerShell code I have a configured Citrix XenDesktop 7 site (or at least I thought so).

While checking the configuration within Citrix Studio, I found out that the licensing information for this environment are missing (which is not a surprise at this point).

So I investigated a bit more time to “fix” this missing configuration piece.

Here is the additional PowerShell Code to configure Citrix Licensing inside Citrix XenDesktop 7.

Note: My Citrix license server is located on a different machine.

Note2: To run Citrix XenDesktop 7 successfully you have to use Citrix Licensing server 11.11.1 (or above).

At the beginning of this code block I have to define some PowerShell variables again.

 $LicenseServer = ""
 $LicenseServer_Port = "27000"
 $LicenseServer_LicensingModel = "UserDevice"
 $LicenseServer_ProductCode = "XDT"
 $LicenseServer_ProductEdition = "PLT"
 $LicenseServer_ProductVersion = "7.0"
 $LicenseServer_AddressType = "WSL"

Short varibles description:

  • ProductCode
    • XDT = XenDesktop
  • AddressType
    • WSL = Web Services for Licensing

Now you can configure the license server information inside the XenDesktop 7 site (be sure you loaded the Citrix PowerShell snapins before).

 Set-ConfigSite  -AdminAddress $env:COMPUTERNAME -LicenseServerName $LicenseServer -LicenseServerPort $LicenseServer_Port -LicensingModel $LicenseServer_LicensingModel -ProductCode $LicenseServer_ProductCode -ProductEdition $LicenseServer_ProductEdition -ProductVersion $LicenseServer_ProductVersion

Now you can verify the license information within the Citrix Studio but you receive an error message regarding a secure communication problem between XenDesktop 7 controller and license server.

After some debugging I found out that you have to store the License server SSL certificate hash inside the XenDesktop database using this cmdlets.

 $LicenseServer_AdminAddress = Get-LicLocation  -AddressType $LicenseServer_AddressType -LicenseServerAddress $LicenseServer -LicenseServerPort $LicenseServer_Port
 $LicenseServer_CertificateHash = $(Get-LicCertificate  -AdminAddress $LicenseServer_AdminAddress).CertHash
 Set-ConfigSiteMetadata  -AdminAddress $env:COMPUTERNAME -Name "CertificateHash" -Value $LicenseServer_CertificateHash
In the next couple of (days and weeks) I will automate more things within XenDesktop 7, so please stay tuned.