Citrix Lifecycle Management Deep Dive

An article by Trond Eirik Haavarstein from xenappblog

In my last post Ultimate Guide to Citrix Lifecycle Management I covered the basics of custom scripts and blueprints to get you started.

Now let’s dive a little bit deeper with some great examples on monitoring. There’s already a LoginVSI blueprint, but let’s add Splunk, uberAgent and ControlUp to the mix.

Since Splunk doesn’t have a direct download URL I’m hosting the media in my Amazon S3 bucket. The script below can be customized to connect to a private FTP server instead. Change $URL on line 13 to point to your media repository.

Install Splunk Enterprise

Write-Verbose "Setting Arguments" -Verbose
$startDTM = (Get-Date)

$Vendor = "Splunk"
$Product = "Enterprise"
$PackageName = "splunk-6.2.5-272645-x64-release"
$InstallerType = "msi"
$Version = "6.2.5"
$LogPS = "${env:SystemRoot}" + "Temp$Vendor $Product $Version PS Wrapper.log"
$LogApp = "${env:SystemRoot}" + "Temp$PackageName.log"
$Destination = "${env:ChocoRepository}" + "$Vendor$Product$Version$packageName.$installerType"
$UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 AGREETOLICENSE=Yes /qn /liewa $LogApp"
$url = "http://xxxxxx.s3.amazonaws.com/splunk-6.2.5-272645-x64-release.msi"
$output = "$env:SystemDriveInstallers$Vendor$Product$Version$PackageName.$InstallerType"

Start-Transcript $LogPS

	if (-not (Test-Path $env:SystemDriveInstallers$Vendor$Product$Version$PackageName.$InstallerType)) {
        Write-Verbose "Starting Download of $Vendor $Product $Version" -Verbose 
		New-Item -Path $env:SystemDriveInstallers$Vendor$Product$Version -ItemType Directory | Out-Null
		$wc = New-Object System.Net.WebClient
		$wc.DownloadFile($url, $output)
		}
	else
		{Write-Verbose "$Vendor $Product $Version Exist" -Verbose}	

CD $env:SystemDriveInstallers$Vendor$Product$Version

Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose 
(Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode

Write-Verbose "Customization" -Verbose

Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript

Next up is ControlUp. That download URL changes with every release, but I’m awaiting a fixed URL from Yoni.

Since the ControlUp and uberAgent download is in a ZIP format you’ll need to install 7Zip prior so it can be extracted by the script.

Install 7Zip (x64)

Write-Verbose "Setting Arguments" -Verbose
$startDTM = (Get-Date)

$Vendor = "Misc"
$Product = "7Zip"
$Version = "9.38"
$PackageName = "7z938-x64"
$InstallerType = "msi"
$LogPS = "${env:SystemRoot}" + "Temp$Vendor $Product $Version PS Wrapper.log"
$LogApp = "${env:SystemRoot}" + "Temp$PackageName.log"
$UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp"
$url = "http://www.7-zip.org/a/7z938-x64.msi"
$output = "$env:SystemDriveInstallers$Vendor$Product$Version$PackageName.$InstallerType"

Start-Transcript $LogPS

	if (-not (Test-Path $env:SystemDriveInstallers$Vendor$Product$Version)) {
        Write-Verbose "Starting Download of $Vendor $Product $Version" -Verbose 
		New-Item -Path $env:SystemDriveInstallers$Vendor$Product$Version -ItemType Directory | Out-Null
		$wc = New-Object System.Net.WebClient
		$wc.DownloadFile($url, $output)
		}
	else
		{Write-Verbose "$Vendor $Product $Version Exist" -Verbose}	

CD $env:SystemDriveInstallers$Vendor$Product$Version

Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose 
(Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode

Write-Verbose "Customization" -Verbose

Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript

Install ControlUp

Write-Verbose "Setting Arguments" -Verbose
$startDTM = (Get-Date)

$Vendor = "Misc"
$Product = "ControlUp"
$PackageName = "ControlUpConsole"
$Version = "4.1"
$InstallerType = "exe"
$LogPS = "${env:SystemRoot}" + "Temp$Vendor $Product $Version PS Wrapper.log"
$LogApp = "${env:SystemRoot}" + "Temp$PackageName.log"
$Destination = "${env:ChocoRepository}" + "$Vendor$Product$Version$packageName.$installerType"
$UnattendedArgs='/sAll /msi /norestart /quiet ALLUSERS=1 EULA_ACCEPT=YES'
$url = "https://ctrlupfeeu01.controlup.com/Downloads/ControlUp/-471804969/ControlUp.zip"
$output = "$env:SystemDriveInstallers$Vendor$Product$VersionControlUp.zip"

Start-Transcript $LogPS

	if (-not (Test-Path $env:SystemDriveInstallers$Vendor$Product$Version)) {
        Write-Verbose "Starting Download of $Vendor $Product $Version" -Verbose 
		New-Item -Path $env:SystemDriveInstallers$Vendor$Product$Version -ItemType Directory | Out-Null
		$wc = New-Object System.Net.WebClient
		$wc.DownloadFile($url, $output)
		$file_dir = "$env:SystemDriveInstallers$Vendor$Product$Version"
		$file_name = "ControlUp.zip"
		$file = Join-Path -Path $file_dir -ChildPath $file_name
		#Locate 7Zip Executable
		$zipPath = "C:Program Files7-Zip7z.exe"
		#Set Alias for 7Zip
		Set-Alias zip $zipPath
		ls alias:zip
		zip x "-o$file_dir" $file
		start-sleep -s 10
		}
	else
		{Write-Verbose "$Vendor $Product $Version Exist" -Verbose}	

CD $env:SystemDriveInstallers$Vendor$Product$Version

Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose 
#(Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode

Write-Verbose "Customization" -Verbose
New-Item -Path $env:ProgramFilesSmart-XControlUp -ItemType Directory -Force | Out-Null
copy-item ControlUpConsole.exe -Destination $env:ProgramFilesSmart-XControlUpControlUpConsole.exe -Recurse
# Create a Shortcut with Windows PowerShell
$TargetFile = "$env:ProgramFilesSmart-XControlUpControlUpConsole.exe"
$ShortcutFile = "$env:PublicDesktopControlUpConsole.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()

Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript

Install uberAgent

Write-Verbose "Setting Arguments" -Verbose
$startDTM = (Get-Date)

$Vendor = "Misc"
$Product = "uberAgent"
$PackageName = "uberAgent-64"
$InstallerType = "msi"
$Version = "3.1.0"
$LogPS = "${env:SystemRoot}" + "Temp$Vendor $Product $Version PS Wrapper.log"
$LogApp = "${env:SystemRoot}" + "Temp$PackageName.log"
$Destination = "${env:ChocoRepository}" + "$Vendor$Product$Version$packageName.$installerType"
$UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp"
$url = "https://uberagent.com/downloads/uberAgent/current/uberAgent.zip"
$output = "$env:SystemDriveInstallers$Vendor$Product$VersionuberAgent.zip"

Start-Transcript $LogPS

	if (-not (Test-Path $env:SystemDriveInstallers$Vendor$Product$Version)) {
        Write-Verbose "Starting Download of $Vendor $Product $Version" -Verbose 
		New-Item -Path $env:SystemDriveInstallers$Vendor$Product$Version -ItemType Directory | Out-Null
		$wc = New-Object System.Net.WebClient
		$wc.DownloadFile($url, $output)
		$file_dir = "$env:SystemDriveInstallers$Vendor$Product$Version"
		$file_name = "uberAgent.zip"
		$file = Join-Path -Path $file_dir -ChildPath $file_name
		#Locate 7Zip Executable
		$zipPath = "C:Program Files7-Zip7z.exe"
		#Set Alias for 7Zip
		Set-Alias zip $zipPath
		ls alias:zip
		zip x "-o$file_dir" $file
		start-sleep -s 10
		}
	else
		{Write-Verbose "$Vendor $Product $Version Exist" -Verbose}

CD "$env:SystemDriveInstallers$Vendor$Product$VersionuberAgent componentsuberAgent_endpointbin"

Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose 
(Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode

Write-Verbose "Customization" -Verbose

Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript

Next step is to add these scripts to your custom blueprint and deploy.

Splunk and ControlUp goes to your Delivery Controller and uberAgent to your VDA’s.

Citrix Lifecycle Management with uberAgent and Splunk 01

It’s really amazing launching the deployment from the cloud and watching VM’s pop up automatically in your private or public cloud.

When the blueprint deployment is running, you can even see the verbose results in the Step Output.

Final step is to configure Splunk and uberAgent. The last one now has it’s own Group Policy so that’s peace of cake.

Citrix Lifecycle Management with uberAgent and Splunk 02

A feature of Citrix Lifecycle Management that many might have missed is the alerts and monitoring section which are really smooth.

Citrix Lifecycle Management with uberAgent and Splunk 04

Hope this post gave you some more insight and ideas to create your own scripts and blueprints.

A final tip is to create a email filter for the Citrix Lifecycle Management notifications and use the Tear Down feature of the Blueprint to delete and cleanup.

Citrix Lifecycle Management with uberAgent and Splunk 05

 

Tags:

Comments

No comments so far.

  • Leave a Reply
     
    Your gravatar
    Your Name