1 Reply Latest reply on Oct 6, 2016 1:21 AM by vXav

    Update VMware Tools

    JimKnopf99 Master

      Hello,

       

      i wan´t to upgrade the vmware tools on a VM that is not running.

      The Workflow should be the following

      1. Power ON VM

      2. Wait until VM AND Tools are running.

      3. Check Version of installed Tools.

      4. If tools are outdated, upgrade tools to version xx

       

      The issue that i have is, after power on the vm. The step Wait until the tools are up and running.

      I check this the following way.

       

      function updatetools{

      $vmtoolsstatus = (Get-VM -name $vm).Guest.Extensiondata.GuestState

       

      if ($vmtoolsstatus -ne "running") {

       

         do {$statustools = (Get-VM -name $vm).Guest.Extensiondata.GuestState

          }until($statustools -eq "running")

          Write-Host "Tools running"

          #Start-Sleep -Seconds "90"

           updatenowtools($vm)

         }

       

         else {

         

              updatenowtools($vm)

       

         }

      }

       

      The Script told me that the tools are up and running but they aren´t. Is there an other way to check this in a do until loop? Or an other loop?

      I don´t wan´t to use the sleep command. Because i need to now if the tools are running or not. Or i have to check the tools again after a sleep period if there is no other way.

       

      Frank

        • 1. Re: Update VMware Tools
          vXav Hot Shot
          vExpert

          I won't get into the whole script but two things that will help you:

           

          IF ($VM.ExtensionData.Guest.ToolsVersionStatus -eq "guestToolsCurrent") {"OK"} ELSE {"Upgrade tools"}

           

          By default the VUM VM baseline upgrades the VM tools at startup so you could simply do :

           

          While (((Get-VM $VM).Guest.ToolsVersionStatus) -ne "guestToolsCurrent") {sleep 5} #Will wait 5 sec every time until the VMtools are current.

           

          The manual thing is to upgrade the virtual hardware (be careful in heterogeneous clusters).

           

           

          Second thing, you can use "| Wait tools" to wait for the tools to respond.

           

          $VM | Wait-Tools  #You can add -TimeoutSeconds to increase the timeout of the command

           

          Be aware that, the fact that the VMtools respond doesn't mean that the OS is ready. It is usually still starting. So if you send commands right after a wait-tools, chances are it will fail. In such case consider adding a sleep or a guest check (test-path)

          1 person found this helpful