Silent Install View Agent
Contents
Upgrade Horizon Agent
No easy way to do this. Consultants and the internet state you need to
- Uninstall Agent
- Reboot
- Uninstall VMTools
- Reboot
- Install VMTools
- Reboot
- Install Agent
There was one desktop that I was unable to gain access, which made it difficult to remove the software. Found an article [5] that explained how to use wmic to remotely remove software. This is the process I am working on to automate some of this process when using full clones instead of linked clones.
Remove Horizon Agent
Invoke-Command -ComputerName testcomputer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Horizon Agent'" | Invoke-Cimmethod -methodname uninstall}
Remove VMTools
- Using CIM instead of WMI
Invoke-Command -ComputerName testcomputer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Tools'" | Invoke-Cimmethod -methodname uninstall}
VMTools Install Options
setup64.exe /s /v"/qn /l*v c:\vtools.log ADDLOCAL=ALL"
Agent Install Options
VMware-Horizon-Agent-x86_64-7.7.0-11054235.exe /v" /qn INSTALL_VDISPLAY_DRIVER=1 /l*v c:\H477.log ADDLOCAL=Core,USB,RTAV,ClientDriveRedirection,ScannerRedirection,GEOREDIR,ThinPrint,SmartCard,VmwVaudio,SdoSensor,PerfTracker"
Full PS Script
WIP
This assumes there is a scheduled task that runs at boot. This task checks for the file "C:\tools_ran.txt", if it does not exist it will create it and install vmtools from a copy of the setup exe.
$computers='testcomputer' $today=date -format yyyyMMdd foreach ($computer in $computers) { if (Invoke-Command -ComputerName $computer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Horizon Agent'"}) { echo "Getting uptime for $computer" $boottime1=(Get-WmiObject -ComputerName $computer win32_operatingsystem).lastbootuptime $boottime2="$boottime1" echo "Boot up time for $computer is $boottime1" echo "Removing Horizon Agent from $computer" Invoke-Command -ComputerName $computer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Horizon Agent'" -erroraction silentlycontinue | Invoke-Cimmethod -methodname uninstall} $reboot="y" } if ("$reboot" -eq "y") { while ("$boottime2" -eq "$boottime1") {$boottime2=(Get-WmiObject -ComputerName $computer win32_operatingsystem -erroraction silentlycontinue).lastbootuptime} echo "Boot time for $computer is now $boottime2" } echo "Removing VMware Tools from $computer" Invoke-Command -ComputerName $computer -ScriptBlock {rm C:\tools_ran.txt; Get-Ciminstance -classname win32_product -filter "name like 'Vmware Tools'" -erroraction silentlycontinue | Invoke-Cimmethod -methodname uninstall -erroraction silentlycontinue} -asjob -erroraction silentlycontinue echo "Sleeping for five minutes" start-sleep -seconds 300 $installdate="0000" echo "Verifying vmtools is installed" while ("$installdate" -ne "$today") {$installdate=Invoke-Command -ComputerName $computer -ScriptBlock {(Get-Ciminstance -classname win32_product -filter "name like 'Vmware Tools'" -erroraction silentlycontinue).installdate} -erroraction silentlycontinue } echo "Installing Agent on $computer" Invoke-Command -ComputerName $computer -ScriptBlock {C:\VMware-Horizon-Agent-x86_64-7.7.0-11054235.exe '/v" /qn INSTALL_VDISPLAY_DRIVER=1 /l*v C:\H477.log ADDLOCAL=Core,USB,RTAV,ClientDriveRedirection,ScannerRedirection,GEOREDIR,ThinPrint,SmartCard,VmwVaudio,SdoSensor,PerfTracker"'} }
- ↑ https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1019862
- ↑ https://pubs.vmware.com/view-50/index.jsp?topic=%2Fcom.vmware.view.administration.doc%2FGUID-0B32D33F-152F-45EC-AC2C-F523D9432426.html
- ↑ https://pubs.vmware.com/horizon-7-view/index.jsp?topic=%2Fcom.vmware.horizon-view.desktops.doc%2FGUID-3096DA8B-034B-435B-877E-5D2B18672A95.html
- ↑ https://pubs.vmware.com/horizon-7-view/index.jsp?topic=%2Fcom.vmware.horizon-view.desktops.doc%2FGUID-1FD90D4D-0C7C-4E9E-B12D-974ABF15E398.html
- ↑ https://community.spiceworks.com/how_to/179-using-a-command-line-to-uninstall-software-on-remote-pcs
- ↑ https://community.spiceworks.com/topic/1077878-powershell-script-to-uninstall-applications-remotely
- ↑ https://social.technet.microsoft.com/Forums/en-US/8ab6ee89-8ec3-47ea-9307-a504b22ad23f/uninstall-software-remotely-with-powershell?forum=ITCG
- ↑ https://docs.microsoft.com/en-us/windows/desktop/wmisdk/wql-sql-for-wmi
- ↑ https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vmtools.install.doc%2FGUID-CD6ED7DD-E2E2-48BC-A6B0-E0BB81E05FA3.html
- ↑ https://docs.vmware.com/en/VMware-vSphere/6.0/com.vmware.vsphere.vm_admin.doc/GUID-E45C572D-6448-410F-BFA2-F729F2CDA8AC.html#GUID-E45C572D-6448-410F-BFA2-F729F2CDA8AC
- ↑ https://docs.vmware.com/en/VMware-Horizon-7/7.7/horizon-virtual-desktops/GUID-3096DA8B-034B-435B-877E-5D2B18672A95.html?hWord=N4IghgNiBcIM4EsIFMB2AXABA1d2QkwAsB7AJwQC8TVMwBzNdEAXyA