From Michael's Information Zone
Jump to: navigation, search

[1] [2] [3] [4]

Upgrade Horizon Agent

No easy way to do this. Consultants and the internet state you need to

  1. Uninstall Agent
  2. Reboot
  3. Uninstall VMTools
  4. Reboot
  5. Install VMTools
  6. Reboot
  7. 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.

[6]

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

[7] [8]

Invoke-Command -ComputerName testcomputer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Tools'" | Invoke-Cimmethod -methodname uninstall}


VMTools Install Options

[9][10]

setup64.exe /s /v"/qn /l*v c:\vtools.log ADDLOCAL=ALL"

Agent Install Options

[11]

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"'}
}