Automating the Install of XenDesktop DDC with PowerShell

I had a need to automate the installation of Citrix XenDesktop DDC including using some of the different available install options.

XenDesktopServerSetup.exe is the command line tool to use. Running XenDesktopServerSetup.exe /? displays most of the options that can be used, however I found a couple missing which are documented here.

The Install-XenDesktopDDC function below will enable you to install XenDesktop with different options. For instance, to install all components, but no SQL Express and see the install steps:

Install-XenDesktopDDC -noSQL -Verbose

The installation can be confirmed by checking for the presence of Citrix services:

Get-Service Citrix\*

or looking in the installation folder:

To install a subset of components using a specified install media location and a custom install path, this time including the default SQL Express install:

Install-XenDesktopDDC -components "CONTROLLER,DESKTOPSTUDIO" -installMediaLocation "X:\\Citrix\\XenDesktop\\5.6" -customInstallLocation "C:\\Citrix"

(Note: I tested the below Install-XenDesktopDDC function with XenDesktop 5.6. It should work with other 5.x versions, but I have not tested those)

.DESCRIPTION Install Citrix XenDesktop Desktop Delivery Controller, with options for different installation types

.PARAMETER components Specify a comma seperated list of Citrix XenDesktop DDC Components to install

.PARAMETER noSQL Prevents the installation of SQL Server Express

.PARAMETER installMediaLocation Specify the location of the Citrix XenDesktop install media, otherwise the CDRom drive is used

.PARAMETER customInstallLocation Specify the location to install Citrix XenDesktop DDC to

.EXAMPLE Install-XenDesktopDDC -noSQL

.EXAMPLE Install-XenDesktopDDC -components "CONTROLLER,DESKTOPSTUDIO" -installMediaLocation "X:\\Citrix\\XenDesktop\\5.6" -customInstallLocation "C:\\Citrix" #> \[CmdletBinding()\]

param( \[Parameter(Position=0)\] \[ValidateNotNullorEmpty()\] \[String\] $components = "CONTROLLER,DESKTOPSTUDIO,DESKTOPDIRECTOR,LICENSESERVER,WEBACCESS",

\[Parameter(Position=1)\] \[Switch\] $noSQL,

\[Parameter(Position=2)\] \[ValidateNotNullorEmpty()\] \[String\] $installMediaLocation,

\[Parameter(Position=3)\] \[ValidateNotNullorEmpty()\] \[String\] $customInstallLocation )

function Get-CDRomDriveLetter { (\[System.IO.DriveInfo\]::GetDrives() | Where-Object {$\_.DriveType -eq "CDRom"}| Select-Object -ExpandProperty RootDirectory).Name }

function Get-ProcessorArchitecture { if ((Get-WmiObject Win32\_OperatingSystem).OSArchitecture -eq "64-bit"){ "x64" } else { "x86" } } Write-Verbose "Determining Install Media Location" if (!$installMediaLocation){ $CDRomDriveLetter = Get-CDRomDriveLetter $processorArchitecture = Get-ProcessorArchitecture $installMediaLocation = "$CDRomDriveLetter$processorArchitecture\\XenDesktop Setup\\" } else { $processorArchitecture = Get-ProcessorArchitecture $installMediaLocation = $installMediaLocation + "\\$processorArchitecture\\XenDesktop Setup\\" }

if (!(Test-Path $installMediaLocation)){ throw "Path to installation media is not valid" }

Write-Verbose "Setting Install Arguments" if ($customInstallLocation){ if (!(Test-Path $customInstallLocation)){ throw "Path to custom install is not valid" } if ($noSQL){ $installerArguments = ('/QUIET','/INSTALLDIR',$customInstallLocation,'/COMPONENTS',$components,'/CONFIGURE\_FIREWALL','/NOREBOOT','/NOSQL') } else { $installerArguments = ('/QUIET','/INSTALLDIR',$customInstallLocation,'/COMPONENTS',$components,'/CONFIGURE\_FIREWALL','/NOREBOOT') } } else { if ($noSQL){ $installerArguments = ('/QUIET','/COMPONENTS',$components,'/CONFIGURE\_FIREWALL','/NOREBOOT','/NOSQL') } else { $installerArguments = ('/QUIET','/COMPONENTS',$components,'/CONFIGURE\_FIREWALL','/NOREBOOT') } }

Write-Verbose "Running the XenDesktop Installation" Push-Location $installMediaLocation Start-Process -FilePath XenDesktopServerSetup.exe -Wait -ArgumentList $installerArguments } ```