2 Replies Latest reply on Jul 13, 2018 11:35 AM by dwiggins17141

    Removing VMware Tool Modules via PowerCLI

    dwiggins17141 Lurker

      I have an issue where we need to removed the Network Instrospection modules from serveral thousand VMs but keep File Instrospection module installed. I have found and adapted the following but I'm getting an error. 

       

      Script:

      Get-VM  | %{

        Mount-Tools -VM $_

        $DriveLetter = Get-WmiObject Win32_CDROMDrive -ComputerName $_.Name | 

          Where-Object {$_.VolumeName -match "VMware Tools"} | Select-Object -ExpandProperty Drive

        $ScriptText = "$DriveLetter\setup64.exe /S /v `"/qn REBOOT=R ADDLOCAL=ALL REMOVE=Hgfs,NetworkIntrospection`""

        Invoke-VMScript -VM $_ -ScriptText $ScriptText -ScriptType bat

      }

       

      Error:

      Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

      At line:3 char:18

      + ... $DriveLetter = Get-WmiObject Win32_CDROMDrive -ComputerName $_.Name |

      +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException

          + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

       

      Thanks for any insight is able to provide.

       

      Get-VM LWVMUTSET007 | %{
        Mount-Tools -VM $_
        $DriveLetter = Get-WmiObject Win32_CDROMDrive -ComputerName $_.Name | 
          Where-Object {$_.VolumeName -match "VMware Tools"} | Select-Object -ExpandProperty Drive
        $ScriptText = "$DriveLetter\setup64.exe /S /v `"/qn REBOOT=R ADDLOCAL=ALL REMOVE=Hgfs,NetworkIntrospection`""
        Invoke-VMScript -VM $_ -ScriptText $ScriptText -ScriptType bat
      }