Another update for upgrading to 2402 LTSR from earlier versions!
The biggest change that I saw in this was the addition of the “/xenapp” switch in the Install_Server.bat and Install_Desktop.bat. For some reason, without that switch, it will not continue. According to the documentation at Install Switches, it says, “Command-line option: /xenapp to install Citrix Virtual Apps. Citrix Virtual Desktops is installed if this option is omitted.” What I found is that it wouldn’t install in either case correctly unless I added that switch. This will still do a WMI check and see if it is a server / desktop class OS and run the appropriate version of the files. This was tested against 2016, 2019, 2022, and multiple versions of Win 10.
$VDIList = Get-Content "C:\scripts\logs\VDAUpgrade.txt"
$source = "location.fqdn\Citrix\XenApp\vdaupgrade-2402"
$dest = "c$\software\vdaupgrade"
$serverInstallFile = "Install_Server.bat"
$serverRemoveFile = "Remove_Server.bat"
$desktopInstallFile = "Install_Desktop.bat"
$desktopRemoveFile = "Remove_Desktop.bat"
$VDAFileServer = "VDAServerSetup_2402.exe"
$VDAFileDesktop = "VDAWorkstationSetup_2402.exe"
$vcenter = "vCenter Address"
$TotalItems = $VDIList.Count
$CurrentItem = 0
$PercentComplete = 0
$date = Get-Date -Format MMddyyyy
$report = @()
if($global:defaultviserver -eq $null){
Connect-VIServer $vcenter
}
if($GLOBAL:XDSDKProxy -eq $null){
Get-XDAuthentication -ProfileName "default"
}
foreach ($VDI in $VDIList) {
Write-Progress -Activity "Starting on $VDI" -Status "$PercentComplete% Complete:" -PercentComplete $PercentComplete
$line = "" | Select-Object Name, PreviousVersion, SnapShot
$VDI1 = ($VDI.Split('.')[0])
$line.Name = "$VDI"
$line.PreviousVersion = (Get-BrokerMachine -HostedMachineName $VDI1 | Select-Object AgentVersion).AgentVersion
$snapshot = (Get-VM $VDI1 | New-Snapshot -name $date-$VDI1-preupgrade)
$line.SnapShot = (Get-VM $VDI1 | Get-Snapshot).Name
$wmiOSTypeCheck = Get-WmiObject -ComputerName $VDI -Class Win32_OperatingSystem | Where-Object {$_.Primary -eq $true}
if($wmiOSTypeCheck.ProductType -eq 3){
$installFile = "$serverInstallFile"
$removeFile = "$serverRemoveFile"
$VDAFile = "$VDAFileServer"
Write-Host "Copying VDA files and installing on server $VDI"
if (!(Test-Path -Path "\\$VDI\c$\software\vdaupgrade")) {
New-Item -ItemType Directory -Path "\\$VDI\c$\software" -Name "vdaupgrade"
Copy-Item "\\$source\$installFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$removeFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$VDAFile" -Destination "\\$VDI\$dest" -Force
}
else {
Copy-Item "\\$source\$installFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$removeFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$VDAFile" -Destination "\\$VDI\$dest" -Force
}
Invoke-Command -ComputerName $VDI -Scriptblock {
$time = (Get-Date).AddMinutes(3)
$action = New-ScheduledTaskAction -Execute 'c:\software\vdaupgrade\Remove_Server.bat'
$trigger = New-ScheduledTaskTrigger -Once -At $time
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAUninstall" -Description "Citrix VDA Uninstall"
}
Invoke-Command -ComputerName $VDI -Scriptblock {
$action = New-ScheduledTaskAction -Execute 'c:\software\vdaupgrade\Install_Server.bat'
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAInstall" -Description "Citrix VDA Install"
}
}
if($wmiOSTypeCheck.ProductType -eq 1){
$installFile = "$desktopInstallFile"
$removeFile = "$desktopRemoveFile"
$VDAFile = "$VDAFileDesktop"
Write-Host "Copying VDA files and installing on desktop $VDI"
if (!(Test-Path -Path "\\$VDI\c$\software\vdaupgrade")) {
New-Item -ItemType Directory -Path "\\$VDI\c$\software" -Name "vdaupgrade"
Copy-Item "\\$source\$installFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$removeFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$VDAFile" -Destination "\\$VDI\$dest" -Force
}
else {
Copy-Item "\\$source\$installFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$removeFile" -Destination "\\$VDI\$dest" -Force
Copy-Item "\\$source\$VDAFile" -Destination "\\$VDI\$dest" -Force
}
Invoke-Command -ComputerName $VDI -Scriptblock {
$time = (Get-Date).AddMinutes(3)
$action = New-ScheduledTaskAction -Execute 'c:\software\vdaupgrade\Remove_Desktop.bat'
$trigger = New-ScheduledTaskTrigger -Once -At $time
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAUninstall" -Description "Citrix VDA Uninstall"
}
Invoke-Command -ComputerName $VDI -Scriptblock {
$action = New-ScheduledTaskAction -Execute 'c:\software\vdaupgrade\Install_Desktop.bat'
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAInstall" -Description "Citrix VDA Install"
}
}
$CurrentItem++
$PercentComplete = [int](($CurrentItem / $TotalItems) * 100)
$report += $line
Start-Sleep -Milliseconds 2500
}
$report
VDAUpgrade.txt
machine1.fqdn
machine2.fqdn
machine3.fqdn
Install_Server.bat
C:\software\vdaupgrade\VDAServerSetup_2402.exe /noreboot /quiet /xenapp /components VDA /controllers "CloudConnector1.fqdn CloudConnector2.fqdn" /disableexperiencemetrics /enable_remote_assistance /enable_real_time_transport /enable_hdx_ports /enable_hdx_udp_ports /masterpvsimage /includeadditional "Citrix Personalization for App-V - VDA","Citrix Profile Management","Citrix Profile Management WMI Plug-in"
C:\Windows\system32\schtasks.exe /delete /tn VDAInstall /f
C:\Windows\system32\schtasks.exe /delete /tn VDAUninstall /f
del c:\software\vdaupgrade\remove.bat /F
del c:\software\vdaupgrade\VDAServerSetup_2402.exe /F
C:\Windows\System32\timeout.exe /t 5
C:\Windows\System32\shutdown.exe /r /t 20 /f
del c:\software\vdaupgrade\install.bat /F
Install_Desktop.bat
C:\software\vdaupgrade\VDAWorkstationSetup_2402.exe /noreboot /quiet /xenapp /components VDA /controllers "CloudConnector1.fqdn CloudConnector2.fqdn" /disableexperiencemetrics /enable_remote_assistance /enable_real_time_transport /enable_hdx_ports /enable_hdx_udp_ports /masterpvsimage /includeadditional "Citrix Personalization for App-V - VDA","Citrix Profile Management","Citrix Profile Management WMI Plug-in"
C:\Windows\system32\schtasks.exe /delete /tn VDAInstall /f
C:\Windows\system32\schtasks.exe /delete /tn VDAUninstall /f
del c:\software\vdaupgrade\remove.bat /F
del c:\software\vdaupgrade\VDAWorkstationSetup_2402.exe /F
C:\Windows\System32\timeout.exe /t 5
C:\Windows\System32\shutdown.exe /r /t 20 /f
del c:\software\vdaupgrade\install.bat /F
Remove_Server.bat
“C:\Program Files\Citrix\XenDesktopVdaSetup\XenDesktopVdaSetup.exe” /REMOVEALL /QUIET /NOREBOOT
C:\Windows\System32\shutdown.exe /r /t 5 /f
Remove_Desktop.bat
"C:\Program Files\Citrix\XenDesktopVdaSetup\XenDesktopVdaSetup.exe" /REMOVEALL /QUIET /NOREBOOT
C:\Windows\System32\shutdown.exe /r /t 5 /f
Leave a Reply