Wilco van Bragt - LinkeIn Wilco van Bragt - Twitter rssa 

Unattended Installation scripts XenDesktop 7.x Part 1

As many people already stated it’s important that you automate repeating tasks as much as possible. Therefore I already published articles in which I shared scripts to install unattended Citrix products like Citrix XenApp 6.5 and Citrix Provisioning Services 6.1. With the release of XenDesktop 7.x I see a shift that only the VDA component is installed unattended and most times the Delivery Controller, StoreFront are installed manually. Also several people already published blogs about the (basic) silent parameters of the XenDesktop installation. So you can wonder why I’m also publishing the scripts. Mainly because I also added additional installation checks including additional hotfixes and updates. I also have RES One Automation blocks available for the installation part of the VDA (including PVS Target Device software) and that part is not yet (much) available in other posts.

 

XenDesktop Delivery Controller




The first step is to install the Delivery Controller. As already stated into the intro the parameters are already mentioned in different blogs and are also documented with the Citrix edocs (http://docs.citrix.com/en-us/xenapp-and-xendesktop/7-6/xad-build-new-enviroment/xad-install-command.html). You also probably need to add some Windows features in advance, which can be achieved via Install-WindowsFeature PowerShell command. I’m added a check of the installation by querying the uninstall registry key Citrix is creating at the end of a successful installation (which also arranges that the installation is shown Programs and Features within Control Panel. As Citrix is using the Citrix Desktop Delivery Controller uninstall key the script can also be used for XenDesktop 7.7. Logically you can remove currently all hotfixes that are available in the script as they are for XenDesktop 7.6 only. At the moment of writing there are now XenDesktop 7.7 hotfixes available.

The script also contains the unattended installation of updates and fixes to the Delivery Controller software. The below shown script installed and also checks the installation (based on the uninstall registry information including the version available in this key). The below shown script for XenDesktop 7.6 Delivery Controller also installs hotfix DStudio 760WX64003, XDPoshModule760WX64002 and the hotfixes of Hotfixes Updates 3 for Delivery Controller 7.6. The script only shows output on the screen, but you can changed easily to log files if needed.

#---------------------------------------------------------------------
#   Script: InstallDeliveryController.ps1
#   Unattended Installation Citrix Delivery Director
#   Creator: Wilco van Bragt
#   Creation Date: 24-11-2015
#---------------------------------------------------------------------
#   Version: 0.1 - By: Wilco van Bragt - Date: 24-11-2015 - Changes: First   Version
#---------------------------------------------------------------------
#   Version: 0.2
#   By: Wilco van Bragt
#   Date:   07-12-2015
#   Changes: Change Studio HF2 to HF3
#---------------------------------------------------------------------

#Start   Script Logging
#---------------------------------

$DateFinish=Get-Date
write-host   "Script started at $DateFinish"

#Define   Variables
#---------------------------------

write-host   "Define Variables"

$SourceDir   = "<<SOURCELOCATION>>"

$DCUninstall="HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Citrix   Desktop Delivery Controller"

$exe="$SourceDir\XD76\x64\XenDesktop   Setup\XenDesktopServerSetup.exe"

$LogDir="C:\TEMP"

#Check   paths

#---------------------------------

write-host   "Checking if paths exists, otherwise those are created"

If   ((Test-Path -path $LogDir) -ne $True)

                    { write-host "$LogDir   does not exit, directory will be created."

                                       New-Item   -Path $LogDir -Type Directory

                    }

#Import   other PowerShell Modules and SnapIns
#---------------------------------

write-host   "Import required PowerShell Modules and/or SnapIns"

Import-Module   ServerManager

#Pre-Checking   Delivery Controller software is already installed
#---------------------------------

Write-Host   "Pre-Checking Delivery Controller software is already installed"

If   ((Test-Path -path "$DCUninstall") -ne $True)

                    { Write-Host "The   checked uninstall key $DCUninstall does not exit. Delivery Controller   software is not yet installed, software will be installed."}

                    else

                    {Write-Host   "Uninstall Delivery Controller Key defined as $DirectorUninstall found.   Delivery Controller software already installed on this machine. Installation   will be cancelled." -ForegroundColor Yellow

   Exit

}

#Install   prerequisites
#---------------------------------

Write-Host   "Start installing prerequisites"

$check   = Get-WindowsFeature | Where-Object {$_.Name -eq "GPMC"}

If   ($check.Installed -ne "True"){

       Install-WindowsFeature GPMC}

$check   = Get-WindowsFeature | Where-Object {$_.Name -eq "GPMC"}

If   ($check.Installed -ne "True"){

       Write-Host "WindowsFeature GPMC   not installed. Exiting script"   -ForegroundColor Red

                                       Exit

                                       }

#Install   Citrix Delivery Controller
#---------------------------------

Write-Host   "Start installing Delivery Controller software"

&   $exe /components 'CONTROLLER,DESKTOPSTUDIO' /nosql /quiet /noreboot   /configure_firewall /logpath "$LogDir" | Out-Null

Write-Host   "Checking installation"

If   ((Test-Path -path "$DCUninstall") -ne $True)

                    { Write-Host "The   checked uninstall key $DCUninstall does not exit. Delivery Controller   installation failed, check the logfile for details." -ForegroundColor   Red

                    Exit

                    }

                    else

                    {Write-Host   "Uninstall Key defined as $DCUninstall found. Citrix Delivery Controller   installation succesfull." -ForegroundColor Green}

#Install   CGPM 7.6 FP3
#---------------------------------

Write-Host   "Install CGPM 7.6 FP3"

start-process   -Filepath "$SourceDir\Hotfix\CitrixGroupPolicyManagement_x64.msi"   -ArgumentList "/quiet /norestart /liewa $LogDir\CGPMFP3.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{00BD4C29-CA9A-4A43-A0A8-AE5F6C1930E8}"

if   ($var.Displayversion -ne "2.5.0.0")

                    {write-host   "CitrixGroupPolicyManagement_x64.msi update failed"   -ForegroundColor Red}

                    else

                    {write-host   "CitrixGroupPolicyManagement_x64.msi update succeeded"   -ForegroundColor Green}

#Install   Hotfix DStudio760WX64003 (Version 7.6.3) For Citrix Studio 7.6 x64 - English
#---------------------------------

Write-Host   "Install Hotfix DStudio760WX64003"

start-process   -Filepath "$SourceDir\Hotfix\DStudio760WX64003.msi" -ArgumentList   "/quiet /norestart /liewa $LogDir\DStudio760WX64002.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{BDE62727-025A-47B1-BBE0-41833CF550CA}"

if   ($var.Displayversion -ne "7.6.3.5029")

                    {write-host   "DStudio760WX64003.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "DStudio760WX64003.msi update succeeded" -ForegroundColor Green}              

#Install   Hotfix XDPoshModule760WX64002 - For XenApp 7.6; XenDesktop 7.6 PowerShell   Module (64-bit) - English
#---------------------------------

Write-Host   "Install Hotfix XDPoshModule760WX64002"

start-process   -Filepath "$SourceDir\Hotfix\XDPoshModule760WX64002.msi"   -ArgumentList "/quiet /norestart /liewa   $LogDir\XDPoshModule760WX64002.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{77FBB1C0-AA17-4BA1-A3E2-3D46779FF7ED}"

if   ($var.Displayversion -ne "7.6.2.5029")

                    {write-host   "XDPoshModule760WX64002.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "XDPoshModule760WX64002.msi update succeeded" -ForegroundColor   Green}

#Install   Hotfixes Update 3 - For Delivery Controller 7.6 (64-bit) - English
#---------------------------------

Write-Host   "Hotfixes Update 3 - For Delivery Controller 7.6"

start-process   -Filepath "$SourceDir\Hotfix\BrokerSrvc760WX64003.msi"   -ArgumentList "/quiet /norestart /liewa   $LogDir\BrokerSrvc760WX64003.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{440A6903-D5B9-417C-B248-B12E0E262560}"

if   ($var.Dispalyversion -ne 7.6.3.5023)

                    {write-host   "BrokerSrvc760WX64003.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "BrokerSrvc760WX64003.msi update succeeded" -ForegroundColor Green

                    $count=1}

                   

start-process   -Filepath "$SourceDir\Hotfix\HostSrvc760WX64003.msi" -ArgumentList   "/quiet /norestart /liewa $LogDir\HostSrvc760WX64003.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{53D7CFEB-B01B-4D7C-97CC-CBF4C9DCFA0D}"

if   ($var.Dispalyversion -ne 7.6.3.5021)

                    {write-host   "HostSrvc760WX64003.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "HostSrvc760WX64003.msi update succeeded" -ForegroundColor Green

                    $count=$count+1}

start-process   -Filepath "$SourceDir\Hotfix\MCSrvc760WX64003.msi" -ArgumentList   "/quiet /norestart /liewa $LogDir\MCSrvc760WX64003.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{404099AF-DDED-46D2-892E-22446162B37E}"

if   ($var.Dispalyversion -ne 7.6.3.5020)

                    {write-host   "MCSrvc760WX64003.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "MCSrvc760WX64003.msi update succeeded" -ForegroundColor Green

                    $count=$count+1}

start-process   -Filepath "$SourceDir\Hotfix\MonitorPSSI760WX64002.msi"   -ArgumentList "/quiet /norestart /liewa   $LogDir\MonitorPSSI760WX64002.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{87DBC684-F1E0-4BA2-BF7E-5BEB3575098E}"

if   ($var.Dispalyversion -ne 7.6.2.5014)

                    {write-host   "MonitorPSSI760WX64002.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "MonitorPSSI760WX64002.msi update succeeded" -ForegroundColor Green

                    $count=$count+1}

start-process   -Filepath "$SourceDir\Hotfix\MonitorSrvc760WX64003.msi"   -ArgumentList "/quiet /norestart /liewa   $LogDir\MonitorSrvc760WX64003.log" -Wait

$var=Get-Itemproperty   "hklm:\software\microsoft\windows\currentversion\uninstall\{90EEA8E9-9049-4E1D-93E0-C1669A236C86}"

if   ($var.Dispalyversion -ne 7.6.3.5014)

                    {write-host   "MonitorSrvc760WX64003.msi update failed" -ForegroundColor Red}

                    else

                    {write-host   "MonitorSrvc760WX64003.msi update succeeded" -ForegroundColor Green

                    $count=$count+1}

if   ($count -eq 5)

                    {write-host "All   Delivery Controller Hotfix 3 updates installed succesfull"}

                    else

                    {write-host "A total   of $count updates out of 5 installed succesfull. Please check the log files   to determine which one has failed" -ForegroundColor Yellow}

#Finalize   Script Logging
#---------------------------------

$DateFinish=Get-Date

write-host   "Script finished at $DateFinish"

As you only configure the XenDesktop site most time only once I did not automate the set-up of the XenDesktop site on the first Delivery Controller (which can be done, maybe at some other project). The following XenDesktop Delivery Controllers can be easily added via one PowerShell command. I created a small PowerShell script, where you only need to add a Delivery Controller name as a parameter.

#---------------------------------------------------------------------
#   Script: DeliveryControllerJoinSite.ps1
#   Unattended Join current XenDesktop Site
#   Creator: Wilco van Bragt
#   Creation Date: 25-11-2015
#---------------------------------------------------------------------
#   Version: 0.1
#   By: Wilco van Bragt
#   Date: 25-11-2015
#   Changes: Initial Release
#---------------------------------------------------------------------

#Start   Script Logging
#---------------------------------

$DateStart=Get-Date

write-host   "Script started at $DateStart"

#Define   Variables
#---------------------------------

write-host   "Define Variables"

$LogDir   = "C:\TEMP"

$1stDeliveryController   = "<<DELIVERYCONTROLLERSERVERNAME>>"

#Import   other PowerShell Modules and SnapIns
#---------------------------------

write-host   "Import required PowerShell Modules and/or SnapIns"

Add-PSSnapin   Citrix.*

#Add   Server to XenDesktop site
#---------------------------------

write-host   "Server $env:computername will be added to the XenDesktop site via   $1stDeliveryController"

Add-XDController   -SiteControllerAddress $1stDeliveryController |Out-Null

write-host   "Server should be added, check Controllers within Citrix Studio if   $env:computername is added"

#Finalize   Script Logging
#---------------------------------

$DateFinish=Get-Date

write-host   "Script finished at $DateFinish"

Summarization

In this first part I shared my unattended script for installing the Citrix XenDesktop Delivery Controller component including a small script to join an existing XenDesktop site. In the upcoming article I will share my scripts for the Virtual Desktop Agent (VDA) including the PVS Target Device software, VDA Optimization and Default User Profile Optimization also as a RES One Automation Building Block.