This post has already been read 4445 times!
I have been working on a Citrix StoreFront build for Windows Server 2016 TP4 and whilst I do like a nice slow manual install (not at all) I thought I would take some of the Citrix Lifecycle Management automation scripts I have written / cobbled together and port them into a local powershell script that can be executed on the server. I have tested this on Windows Server 2016 TP 3 and 4 and it seems to work ok. Feel free to copy / edit / improve / ignore the script as you wish. You will need to download the CitrixStoreFront-x64.exe file from Citrix and put it into a C:\Installers folder then run the script. It will display the output to the screen as well as set up and log into the Windows Event Log. Below is the script – hope it help some of you out. Laters, b@m
$global:EventLog = "Automation Framework" $global:InstallerPath = (get-location).Drive.Name + ":\installers" function SetEventLog($logName) { $logFileExists = Get-EventLog -list | Where-Object {$_.logdisplayname -eq $logName} if (! $logFileExists) { New-EventLog -LogName $logName -Source $logName LogBad "Event Log Does Not Exist!" LogOK "Creating Event Log - $logName" } else { LogOK "The Event Log $logName Already Exists" } }
function LogOK($logText) { write-host $logText -foregroundcolor "green" Write-Eventlog -Logname $EventLog -Message $logText -Source $EventLog -id 1 -entrytype Information -Category 0 }
function LogBad($logText) { write-host $logText -foregroundcolor "red" Write-Eventlog -Logname $EventLog -Message $logText -Source $EventLog -id 1 -entrytype Error -Category 0 }
function AddWindowsFeature($ServiceName) { Import-Module ServerManager $srv = Get-WindowsFeature $ServiceName if (! $srv.installed) { LogOK "Adding Windows Feature $ServiceName" Add-WindowsFeature -Name $ServiceName -IncludeAllSubFeature LogOK "$ServiceName Added" } else { LogOK "The Windows Service $ServiceName Is Already Installed" } }
function AddWindowsFeatureSingle($ServiceName) { Import-Module ServerManager $srv = Get-WindowsFeature $ServiceName if (! $srv.installed) { LogOK "Adding Windows Feature $ServiceName" Add-WindowsFeature -Name $ServiceName LogOK "$ServiceName Added" } else { LogOK "The Windows Service $ServiceName Is Already Installed" } }
function SetupInstallers { if (!(Test-Path -Path $InstallerPath)) { LogBad "Installers Path Not Found - Creating Path" New-Item -ItemType directory -Path $InstallerPath } else { LogOK "Installer Directory Already Found" } }
function DownloadWebFile([string]$url, [string]$localFile) { $client = New-Object System.Net.WebClient $localDFile = $InstallerPath + "\" + $localFile if (!(Test-Path $localDFile)) { LogBad "File Not Found - Downloading from $url to $localDFile" $client.DownloadFile($url, $localDFile) } else { LogOK "File Found - $localDFile" } }
function InstallMSI($localFile, $softwareName) { $InstalledYet = Get-WmiObject Win32_Product | Where {$_.Name -eq "$softwareName"} if ($InstalledYet -ne $null) { LogOK "Software is already installed - $softwareName" } else { LogBad "Software is NOT installed - $softwareName" $argumentlist = "/i $InstallerPath\[application].msi /qb /l*v $InstallerPath\[application].log" $argumentlist = $argumentlist.Replace("[application]",$localFile) LogOK "Installing Application - $argumentlist" Start-Process -FilePath "msiexec.exe" -ArgumentList $argumentlist -wait } }
function InstallEXE($localFile, $parameters, $softwareName) { $InstalledYet = Get-WmiObject Win32_Product | Where {$_.Name -eq "$softwareName"} if ($InstalledYet -ne $null) { LogOK "Software is already installed - $softwareName" } else { LogBad "Software is NOT installed - $softwareName" LogOK "Installing Application - $softwareName" Start-Process -FilePath "$InstallerPath\$localFile" -ArgumentList $parameters -wait } }
function ConfigureStoreFront ($hostBaseURL, $Farmname, $Port, $TransportType, $sslRelayPort, $Servers, $LoadBalance, $FarmType, $svp, $svwp) { . "C:\Program Files\Citrix\Receiver StoreFront\Scripts\ImportModules.ps1" $svpMod = $svp.Replace("/","\") $storePath = "C:\InetPub\wwwroot" + $svpMod if (!(Test-Path -Path $storePath)) { LogBad "Store NOT Found - $storePath" LogOK "Importing Modules - C:\Program Files\Citrix\Receiver StoreFront\Scripts\ImportModules.ps1" LogOK "Running Command to Setup Store - Set-DSInitialConfiguration -hostBaseUrl $HostBaseURL -farmName $Farmname -port $Port -transportType $TransportType -sslRelayPort $sslRelayPort -servers $Servers -loadBalance $LoadBalance -farmType $FarmType -storevirtualpath $svp -webreceivervirtualpath $svwp" Set-DSInitialConfiguration -hostBaseUrl $HostBaseURL -farmName $Farmname -port $Port -transportType $TransportType -sslRelayPort $sslRelayPort -servers $Servers -loadBalance $LoadBalance -farmType $FarmType -storevirtualpath $svp -webreceivervirtualpath $svwp } else { LogOK "Store Found - $storePath" } }
SetEventLog $EventLog AddWindowsFeatureSingle "Web-Net-Ext45" AddWindowsFeatureSingle "Web-AppInit" AddWindowsFeatureSingle "Web-ASP-Net45" AddWindowsFeatureSingle "Web-ISAPI-Ext" AddWindowsFeatureSingle "Web-ISAPI-Filter" AddWindowsFeatureSingle "Web-Default-Doc" AddWindowsFeatureSingle "Web-HTTP-Errors" AddWindowsFeatureSingle "Web-Static-Content" AddWindowsFeatureSingle "Web-HTTP-Redirect" AddWindowsFeatureSingle "Web-HTTP-Logging" AddWindowsFeatureSingle "Web-Filtering" AddWindowsFeatureSingle "Web-Windows-Auth" SetupInstallers InstallEXE "CitrixStoreFront-x64.exe" "-silent" "Citrix StoreFront" ConfigureStoreFront "http://storefront.bretty.me.uk" "bretty" "80" "HTTP" "80" "dc01.bretty.me.uk" $false "XenApp" "/Citrix/bretty" "/Citrix/brettyWeb"