1 Reply Latest reply on Dec 3, 2019 12:05 AM by LucD

    Shutdown-VMGuest

    MariusRoma Hot Shot

      I have a script contining the Shutdown-VMGuest command.

      I had a problem because the script was executed during the night and hung after issuing the Shutdown-VMGuest because the VMwate tools inside the VM were stopped.

      The following instructions (including a check on the state of the VM) were not executed.

      Is there any way to control the execution of the command, i.e. getting a result or a return code, something like:

       

      $success = Shutdown-VMGuest

       

      Regards

      marius

       

        • 1. Re: Shutdown-VMGuest
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Not really

          There are a couple of ways to avoid this issue.

          • Check if the VMware Tools are running and ready before running the Stop-VMGuest cmdlet. More specifically look at the $vm.ExtensionData.Guest.GuestOperationsReady
          • Use Invoke-VMScript, again after checking if the VMware Tools are ready, and run the shutdown command from there. Make sure the Invoke-VMScript returns and then in a loop check if the VM is powered off. You can place a timeout on that loop.