Difference between revisions of "Silent Install View Agent"

From Michael's Information Zone
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 15: Line 15:
 
<br>
 
<br>
 
There was one desktop that I was unable to gain access, which made it difficult to remove the software. Found an article <ref>https://community.spiceworks.com/how_to/179-using-a-command-line-to-uninstall-software-on-remote-pcs</ref> 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.
 
There was one desktop that I was unable to gain access, which made it difficult to remove the software. Found an article <ref>https://community.spiceworks.com/how_to/179-using-a-command-line-to-uninstall-software-on-remote-pcs</ref> 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.
 +
 +
<ref>https://community.spiceworks.com/topic/1077878-powershell-script-to-uninstall-applications-remotely</ref>
  
 
===Remove Horizon Agent===
 
===Remove Horizon Agent===
<ref>https://community.spiceworks.com/topic/1077878-powershell-script-to-uninstall-applications-remotely</ref>
+
<pre>Invoke-Command -ComputerName testcomputer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Horizon Agent'" | Invoke-Cimmethod -methodname uninstall}</pre>
<pre>Get-WmiObject -Class win32_product -ComputerName "testcomputer" | where {$_.name -match 'vmware tools'}</pre>
+
 
 +
===Remove VMTools===
 +
*Using CIM instead of WMI
 +
<ref>https://social.technet.microsoft.com/Forums/en-US/8ab6ee89-8ec3-47ea-9307-a504b22ad23f/uninstall-software-remotely-with-powershell?forum=ITCG</ref>
 +
<ref>https://docs.microsoft.com/en-us/windows/desktop/wmisdk/wql-sql-for-wmi</ref>
 +
<pre>Invoke-Command -ComputerName testcomputer -ScriptBlock {Get-Ciminstance -classname win32_product -filter "name like 'Vmware Tools'" | Invoke-Cimmethod -methodname uninstall}</pre>
 +
 
  
 
===VMTools Install Options===
 
===VMTools Install Options===
Line 27: Line 35:
 
<ref>https://docs.vmware.com/en/VMware-Horizon-7/7.7/horizon-virtual-desktops/GUID-3096DA8B-034B-435B-877E-5D2B18672A95.html?hWord=N4IghgNiBcIM4EsIFMB2AXABA1d2QkwAsB7AJwQC8TVMwBzNdEAXyA</ref>
 
<ref>https://docs.vmware.com/en/VMware-Horizon-7/7.7/horizon-virtual-desktops/GUID-3096DA8B-034B-435B-877E-5D2B18672A95.html?hWord=N4IghgNiBcIM4EsIFMB2AXABA1d2QkwAsB7AJwQC8TVMwBzNdEAXyA</ref>
 
<pre>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"</pre>
 
<pre>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"</pre>
 +
 +
===Full PS Script===
 +
WIP
 +
<br>
 +
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.
 +
<pre>
 +
$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"'}
 +
}
 +
</pre>
 +
 
<br>
 
<br>
 
<br>
 
<br>
 
<br>
 
<br>

Latest revision as of 15:40, 14 February 2019

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