XenDesktop 7 Creating site via PowerShell

8:03 PM
XenDesktop 7 Creating site via PowerShell -

Why automate XenDesktop 7 Creating site?

XenDesktop 7 for a while now and after some implementations of PoC I recently got into the situation of having to install and configure a site XenDesktop 7 with bases separate data is our best practice for production environments.

As you may know with XenDesktop 7, in addition to the site configuration database two data stores are created that are initially contained in the basic site data when you are manual configuration via Citrix studio:

configuration logging database - capture the site configuration changes and administrative activities
monitoring database - capture historical performance data for analysis via Citrix Director

of course, it is easily possible to change the database after the site was created via Citrix studio, but always involves manual intervention after and we do not want that, do we? Also it would be good to cover several configuration steps automatically.

There are already enough good information and code snippets out there in the internet covering different parts of a building site unsupervised XenDesktop 7, including the creation of databases. I thought it would be interesting to combine things PowerShell there and building a script for automated complete installation of a site XenDesktop 7 including the license server and role configuration.

As regarding the workflow by automating Citrix provides an excellent Powershell SDK for XenDesktop. From XenDesktop 7, it is now possible for the first time to create databases via PowerShell that will be needed for a complete configuration based on a script. Orders that are contained in a separate module called PowerShell Citrix.XenDesktop.Admin . The "standard" commands for configuration and administration are accessible via XenDesktop PowerShell snap-ins standard. Details about snap-ins can be found here: http://support.citrix.com/proddocs/topic/xendesktop-7/cds-sdk-cmdlet-help.html

PowerShell Scripting for the creation of sites and configuration

So here we go. Although the script has been tested, you should check the code in a test environment before using it for productive environment. It is intended to be run on the first delivery controller after the basic installation

First we have to import the module Citrix.XenDesktop.Admin and add the Citrix snap-ins PowerShell standards :.

  import-module  Citrix.XenDesktop.Admin  Add-PSSnapin  Citrix. * 

Next we define the parameters that need to be adapted to each environment, including the database server, database name, site name, security group for the administration and all the details license server. The possible values ​​for the LicenseServer_LicensingModel variables are UserDevice and Competitors . LicenseServer_ProductEdition may be one of STD, ENT or PLT . To use XenApp licenses for XenDesktop 7 App edition set LicenseServer_ProductCode to MPS .

 $ DatabaseServer =  "dbserver.domain. Com"  $ DatabaseName_Site =  "XD7-DB_Site"  $ DatabaseName_Logging =  "XD7 -DB_Logging " $ DatabaseName_Monitor = " XD7-DB_Monitor " $ XD7Site = " XD7Site " $ FullAdminGroup = " domain  FullAdminGroup " $ LicenseServer =  "licenseserver.domain.com"  $ LicenseServer_LicensingModel =  "UserDevice"  $ LicenseServer_ProductCode =  "XDT"  $ LicenseServer_ProductEdition =  "PLT"  

to create the database, we will need a user with at least dbcreator and securityadmin permissions on the database server . To allow the script to run in a client environment without exposing passwords (which you should never do in a script), we rely on a PSCredential object that stores the password as a SecureString:

 $ DatabaseUser =  Read-Host  "please enter the user to connect (Domain  Username) database" $ DatabasePassword =  Read- Host  "please enter the password for user $ DatabaseUser" -AsSecureString $ Database_CredObject =  New-Object System.Management.Automation.PSCredential  ($ DatabaseUser, $ DatabasePassword) 

now that all the parameters are defined, we can create the separate site, Configuration Registration and monitoring of databases via the New XDDatabase command that creates the database and the schema for XenDesktop on the database server. Note the -DataStore to define the schema to create:

  New XDDatabase  -AdminAddress $ env: COMPUTERNAME -SiteName $ XD7Site - DataStore website -DatabaseServer DatabaseServer -databasename $ $ $ DatabaseName_Site -DatabaseCredentials Database_CredObject  New XDDatabase  -AdminAddress $ env: COMPUTERNAME -SiteName $ XD7Site -DataStore Logging -DatabaseServer DatabaseServer -databasename $ $ $ DatabaseName_Logging -DatabaseCredentials Database_CredObject  New XDDatabase  $ -AdminAddress env: COMPUTERNAME -SiteName $ XD7Site -DataStore Monitor -DatabaseServer DatabaseServer -databasename $ $ $ DatabaseName_Monitor -DatabaseCredentials Database_CredObject 

now, we are ready to create and configure the site with our newly created databases:

  New XDSite  $ -DatabaseServer DatabaseServer -LoggingDatabaseName DatabaseName_Logging -MonitorDatabaseName $ $ $ DatabaseName_Monitor -SiteDatabaseName DatabaseName_Site - SiteName $ XD7Site -AdminAddress $ env: COMPUTERNAME 

so we have the database and the site created, but we still need to configure licenses. An important step here is to store the SSL certificate hash license server from the XenDesktop database to enable trusted communication with the license service.

  Set-XDLicensing  -AdminAddress $ env: COMPUTERNAME -LicenseServerAddress $ LicenseServer -LicenseServerPort 27000  Set-ConfigSite  -AdminAddress $ env: COMPUTERNAME - LicensingModel LicenseServer_LicensingModel -ProductCode $ $ $ LicenseServer_ProductCode -ProductEdition LicenseServer_ProductEdition  Set-ConfigSiteMetadata  -AdminAddress $ env: COMPUTERNAME -Name 'CertificateHash' $ -Value ( "https: // $ LicenseServer" Get-LicCertificate -AdminAddress). certhash 

Almost made to the basic configuration, we only have to define a group Active Directory is configured with full administrator role for the site:

  New AdminAdministrator  -AdminAddress $ env: COMPUTERNAME -Name $ FullAdminGroup  Add-AdminRight  -AdminAddress $ env: COMPUTERNAME -Administrator $ FullAdminGroup -Role 'Full administrator' -All 

therefore, building on a scripted approach to the site and the initial database creation, you can save time, avoid manual reconfiguration database for recording and monitoring and to fully automate installations. Enjoy !

Here you can see the whole script:

Previous
Next Post »
0 Komentar