5 Replies Latest reply on Apr 12, 2019 12:51 PM by LucD

    invoke-vmscript an error occured while sending the request

    sjesse Master
    vExpert

      The error is mentioning that i may be related to the vmware tools being too low, which I need to check, if it is should I just downgrade my powercli version if I can't restart these

       

      Here is the basic script I'm running

       

      $vms=Get-VM

      foreach ($vm in $vms)

      {

          Invoke-VMScript -VM $vm -ScriptText $script -GuestUser $guestuser -GuestPassword $guestpassword

      }

       

      and the error

       

        • 1. Re: invoke-vmscript an error occured while sending the request
          LucD Guru
          vExpertUser ModeratorsCommunity Warriors

          The VMware Tools version might be related to the issue, but necessarily so.

          Are the VMware Tools running?

          Are they ready to accept guest operations?

          Check with

           

           

          Get-VM -Name MyVM |

          Select Name,

             @{N='Tools';E={$_.ExtensionData.Guest.ToolsRunningStatus}},

             @{N='GuestOperationsReady';E={$_.ExtensionData.Guest.GuestOperationsReady}}

           

          Can you upgrade the VMware Tools?
          I don't think downgrading PowerCLI would be the way to go.

           

          Are there any further indications in the vmware.log file?

          You can find it in the VM's folder.

           

          You might also consider enabling debugging for VMware Tools.

          See KB1007873

           

          An other option is to use my Invoke-VMScriptPlus function, the verbosity of that function is a bit higher than the one in the cmdlet.

          • 2. Re: invoke-vmscript an error occured while sending the request
            sjesse Master
            vExpert

            These are horizon virtual desktops  and when I upgrade the tools I can just fix the problem since they are based on a clone, but I can't do that till the end of the month because we have a policy that only forces a restart once a month.

             

            The tools are running ( using 10.2.5), and says guest operations is ready.

             

            In the vmware.log the only thing I say that looks related around a time I tried this this

             

            2019-04-12T17:30:22.779Z| vmx| I125: GuestRpc: Got error for channel 2 connection 103: Remote disconnected

            2019-04-12T17:30:23.779Z| vmx| I125: GuestRpc: Got error for channel 2 connection 104: Remote disconnected

            2019-04-12T17:32:04.033Z| vmx| I125: GuestRpc: Got error for channel 2 connection 204: Remote disconnected

            2019-04-12T17:34:39.155Z| vmx| I125: VigorTransportProcessClientPayload: opID=e869c01-93-f57b seq=820: Receiving GuestOps.CreateTemporaryFile request.

            2019-04-12T17:34:39.180Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=e869c01-93-f57b seq=820: Completed GuestOps request.

            2019-04-12T17:34:39.197Z| vmx| I125: VigorTransportProcessClientPayload: opID=276c0d1a-fd-f580 seq=832: Receiving GuestOps.StartProgram request.

            2019-04-12T17:34:39.248Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=276c0d1a-fd-f580 seq=832: Completed GuestOps request.

            2019-04-12T17:34:39.266Z| vmx| I125: VigorTransportProcessClientPayload: opID=26d03a2e-cd-f588 seq=844: Receiving GuestOps.ListProcesses request.

             

            I'll debug mode and your function and see if I can figure it out. The tools version is supported by the interopability matrix for the powercli version , vcenter version, and horizon version so I'm not sure what the issue would be.

            • 3. Re: invoke-vmscript an error occured while sending the request
              LucD Guru
              Community WarriorsvExpertUser Moderators

              From the log you can see that everything seems to be going ok, up until the command/script is started.

              Then it uses ListProcesses to wait till the command/script finishes.

              After that, the output temp file will be transferred back to from where you launched the Invoke-VMScript.

               

              Is that ListProcesses the last entry?

              Anything after that?

              • 4. Re: invoke-vmscript an error occured while sending the request
                sjesse Master
                vExpert

                I got it work, when I tried your function, I got an tls error. I've seen that before so I added

                 

                 

                 

                add-type @"

                using System.Net;

                using System.Security.Cryptography.X509Certificates;

                public class TrustAllCertsPolicy : ICertificatePolicy {

                    public bool CheckValidationResult(

                        ServicePoint srvPoint, X509Certificate certificate,

                        WebRequest request, int certificateProblem) {

                        return true;

                    }

                }

                "@

                $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'

                [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

                [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

                 

                To make sure it accepts all scripts and now it correctly runs it. None of these desktops will have valid ssl certificates, is this the best way of handling that.

                • 5. Re: invoke-vmscript an error occured while sending the request
                  LucD Guru
                  vExpertUser ModeratorsCommunity Warriors

                  Yes, at this point in time that is, besides installing certs, the best solution.
                  Perhaps create a PowerCLI Idea to add an option to ignore the certificate check (like Invoke-WebRequest has in PS v6)