Skip to content

Instantly share code, notes, and snippets.

@rpunt
Last active June 21, 2017 18:02
Show Gist options
  • Save rpunt/5134848 to your computer and use it in GitHub Desktop.
Save rpunt/5134848 to your computer and use it in GitHub Desktop.
A fully-automated, silent install for XenApp 6 Enterprise on Server 2008 R2.
# This install assumes a couple things:
#
# 1. You're logged in as a local admin, per Citrix recommendations
# 2. These script files are store in d:\software\citrix6
# 3. The installation media for XenApp 6 has been unpacked in d:\software\citrix6\citrix6
# 4. The MSIs for Hotfix Rollup 2 and Profile Manager are located in d:\software\citrix6\citrix6\addons
# (these can be excluded by skipping "04-01-install-patches.bat"
#
# This install occurs across four reboots, and is complete unattended; you can kick it off
# when logged in via RDP or at the console, and let it run to completion. Run time is
# approximately 30 minutes, depending on your environment.
# NOTE: you should be logged in as a local admin, and use those credentials for these parameters
[CmdletBinding()]
param (
[parameter(Mandatory=$true)][string]$adminuser,
[parameter(Mandatory=$true)][string]$adminpassword
)
$log=Join-Path (Get-ChildItem $MyInvocation.MyCommand.Definition).Directory (Get-ChildItem $MyInvocation.MyCommand.Definition).Basename
Start-Transcript "$log.log"
import-module servermanager
# install the prereqs that do not require a restart
add-windowsfeature AS-NET-Framework -restart
add-windowsfeature GPMC -restart
add-windowsfeature web-default-doc,Web-Asp-Net,web-net-ext,web-isapi-ext,web-isapi-filter,web-windows-auth,web-filtering,Web-Mgmt-Compat,Web-Metabase,Web-WMI,Web-Lgcy-Scripting,Web-Lgcy-Mgmt-Console,Web-Http-Errors,Web-Http-Redirect,Web-Client-Auth,Web-Scripting-Tools,Web-Static-Content -restart
add-windowsfeature MSMQ-Server -restart
add-windowsfeature WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs -restart
$computer = gc env:computername
# did you enter credentials for a local user? If so, proceed; else correct it on the next script invocation
[Reflection.Assembly]::LoadFile('C:\Windows\assembly\GAC_MSIL\System.DirectoryServices\2.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll')
Add-Type -assemblyname system.DirectoryServices.accountmanagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
if ($DS.ValidateCredentials($adminuser, $adminpassword)) {
# auto-login three times to complete all stages of the install
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "AutoAdminLogon" -Value 1 -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "ForceAutoLogon" -Value 1 -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "AutoLogonCount" -Value 3 -PropertyType "DWord" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "DefaultDomainName" -Value $computer -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "DefaultUserName" -Value $adminuser -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" -Name "DefaultPassword" -Value $adminpassword -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" -Name "Title" -Value "Installing XenApp" -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\101\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\101" -Name "(Default)" -Value "Installing initial configuration..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\101" -Name "1" -Value 'msiexec.exe /i "D:\Software\Citrix6\Citrix6\XenApp Server Configuration Tool\ServerConfigurationInstall.msi" ALLUSERS=1' -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\102\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\102" -Name "(Default)" -Value "Installing XenApp 6..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\102" -Name "1" -Value '"D:\Software\Citrix6\Citrix6\XenApp Server Setup\bin\XenAppSetupConsole.exe" /install:XenApp,XA_IISIntegration /Enterprise /logfile:d:\software\citrix6\install-xenapp.log' -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\103\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\103" -Name "(Default)" -Value "Initializing Stage 3..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\103" -Name "1" -Value 'c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe "d:\Software\Citrix6\02-01-set-stage3.ps1"' -PropertyType "String" -Force
# this feature requires a reboot to install
add-windowsfeature RDS-RD-Server -restart
} else {
echo "invalid username or password, please try again"
}
$log=Join-Path (Get-ChildItem $MyInvocation.MyCommand.Definition).Directory (Get-ChildItem $MyInvocation.MyCommand.Definition).Basename
Start-Transcript "$log.log"
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" -Name "Title" -Value "Configuring XenApp" -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\201\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\201" -Name "(Default)" -Value "Joining Farm..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\201" -Name "1" -Value 'd:\Software\Citrix6\02-02-join-farm.bat' -PropertyType "String" -Force
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\202\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\202" -Name "(Default)" -Value "Initializing Stage 3..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\202" -Name "1" -Value 'c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe "d:\Software\Citrix6\03-01-set-stage4.ps1"' -PropertyType "String" -Force
restart-computer
REM This is it's own batchfile because it never worked quite right form RunOnceEX
"d:\software\citrix6\citrix6\XenApp Server Configuration Tool\XenAppConfigConsole.exe" /ExecutionMode:Join /FarmName:"FARM_NAME" /ZoneName:"Default Zone" /AddUsersGroupToRemoteDesktopUserGroup:True /AuthenticationType:sql /DsnFile:d:\software\citrix6\citrix6.dsn /OdbcUsername:DOMAIN\ODBC_USER /odbcPassword:ODBC_PASSWORD /log:d:\software\citrix6\joinfarm.log
$log=Join-Path (Get-ChildItem $MyInvocation.MyCommand.Definition).Directory (Get-ChildItem $MyInvocation.MyCommand.Definition).Basename
Start-Transcript "$log.log"
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" -Name "Title" -Value "Configuring XenApp Postrequisites..." -PropertyType "String" -Force
# some recommended settings from Citrix; YMMV
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301" -Name "(Default)" -Value "Initializing Registry Keys..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301" -Name "1" -Value 'reg add "HKLM\SYSTEM\CurrentControlSet\Control" /v "RegistrySizeLimit" /t REG_DWORD /d 0x0df5e100 /f' -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301" -Name "2" -Value 'reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "SessionPoolSize" /t REG_DWORD /d 0x00000040 /f' -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301" -Name "3" -Value 'reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "SessionViewSize" /t REG_DWORD /d 0x00000068 /f' -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\301" -Name "4" -Value 'reg add "HKLM\SYSTEM\CurrentControlSet\services\TermService" /v "LogoffTimeout" /t REG_DWORD /d 0x00000078 /f' -PropertyType "String" -Force
# skip this if you're not installing any postreqs
New-Item -path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\302\" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\302" -Name "(Default)" -Value "Installing Additional Software..." -PropertyType "String" -Force
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\302" -Name "1" -Value 'd:\Software\Citrix6\04-01-install-patches.bat' -PropertyType "String" -Force
restart-computer
REM This is it's own batchfile because it never worked quite right from RunOnceEX
start /wait msiexec.exe /update d:\Software\Citrix6\AddOns\XA600W2K8R2X64R02.msp /qb /norestart
start /wait msiexec.exe /i d:\Software\Citrix6\AddOns\profilemgt4.1.1_x64.msi /qb /norestart
shutdown /r /t 5
[ODBC]
DRIVER=SQL Server
DATABASE=DATABASE_NAME
APP=Citrix IMA
UID=YOUR_USERNAME
SERVER=DATABASE_SERVER
Trusted_Connection=Yes
@rhatfield12
Copy link

If you are still responding to this post..
Question: the script does the first part correctly installing XenApp It did not go to the next step of script 2 the config even though it was in runonceEX.. is the /103 not supposed to execute?? the Role Manager opens after the initial install and sits there nothing else.. Reboot and it does try to do config but doesn't execute the script successfully.

Any quick clues ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment