Highlighted
Enthusiast
Enthusiast

Error running Invoke-Vmscript - An error occurred while sending the request. FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Jump to solution

(EDIT: Same issue already reported here: Invoke-VMScript - An error occurred while sending the request )

Hello folks,

I used to run Invoke-Vmscript againts our Environment to automate Template Creation.
Recently it stopped working, not sure when exactly.  Targeted VM's OS is "Server 2016".

For example when I'm running the following PoSh:

Invoke-VMScript -ScriptText "get-service" -VM $VM -GuestCredential (get-credential)

I'm getting the following Error:

Invoke-VMScript : 02.04.2019 11:54:59   Invoke-VMScript         An error occurred while sending the request.

At line:1 char:1

+ Invoke-VMScript -ScriptText "get-service" -VM $VM -GuestUser Administ ...

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

    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], ViError

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViC

   ore.Cmdlets.Commands.InvokeVmScript


Credentials are correct, I'm seeing a confirmation in the VM Eventlog that the user was sucessfully authenticated. (Eventsource: VGauth, EventID: 1000, Message: vmtoolsd: Username and password successfully validated for 'Administrator')
I also see a brief appearance of a cmd.exe in Taskmanager on the VM.
No other related Events in Eventlog.

Also tried different Clients to run the script, and different target VMs too.
I also ensured that the Client running the script is able to access the ESX Host via Port 443 and (because I read it somewhere: 902 works also)

No more ideas... anyone else? Smiley Happy Thanks for any help!

1 Solution

Accepted Solutions
Highlighted
Enthusiast
Enthusiast

LucD​: thanks to your Invoke-VMScriptPlus I was able to find the problem.

Apparently to get the result both your script and the original cmdlet connect to the esx host via ip and not via dns name.

This break the certificate trust ( I changed the default root-ca in the vcenter and the new certificates issued by it do not contain the IP address in the dns alternaticve subject) and unlike your script the Invoke-VMScript doesn't report a good error.

I temporary add this to my script to ignore the certificate problem:

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;

  }

}

"@

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

I guess there is not way to change this behavior?

By the way set the powercli to ignore the certificate problem using "Set-PowerCLIConfiguration -InvalidCertificateAction Ignore" doesn't work

View solution in original post

34 Replies
Highlighted
Enthusiast
Enthusiast

Did you validated the status of VMware tool?

0 Kudos
Highlighted
User Moderator
User Moderator

Any clues in the vmware.log (in the VM's folder)?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
User Moderator
User Moderator

Any resemblance to this thread Invoke-VMScript - An error occurred while sending the request ?
Does it work when connected to the ESXi node but not when connected to the vCenter?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Highlighted
Enthusiast
Enthusiast

Hi and thank you indeed, it works using directly the ESX.

I seem to have the same problem as Invoke-VMScript - An error occurred while sending the request
didn't found this thread before...

0 Kudos
Highlighted
Enthusiast
Enthusiast

Yeah, VM ware tools seem to work good, since I can use Invoke-VMscript when connected to the ESXi Node directly.

0 Kudos
Highlighted
User Moderator
User Moderator

Same environment?

vSphere 6.7 and PowerCLI 11.2?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Highlighted
Enthusiast
Enthusiast

In the VMware.log is Nothing that I can make sense of:

2019-04-02T11:35:50.589Z| vmx| I125: VigorTransportProcessClientPayload: opID=3f98264b-3a-b9af seq=602231: Receiving GuestOps.CreateTemporaryFile request.

2019-04-02T11:35:50.773Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=3f98264b-3a-b9af seq=602231: Completed GuestOps request.

2019-04-02T11:35:50.788Z| vmx| I125: VigorTransportProcessClientPayload: opID=70df96d8-b6-b9b5 seq=602243: Receiving GuestOps.StartProgram request.

2019-04-02T11:35:50.868Z| vcpu-1| I125: VigorTransport_ServerSendResponse opID=70df96d8-b6-b9b5 seq=602243: Completed GuestOps request.

2019-04-02T11:35:50.892Z| vmx| I125: VigorTransportProcessClientPayload: opID=672878cc-b8-b9bb seq=602255: Receiving GuestOps.ListProcesses request.

2019-04-02T11:35:51.003Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=672878cc-b8-b9bb seq=602255: Completed GuestOps request.

2019-04-02T11:35:56.025Z| vmx| I125: VigorTransportProcessClientPayload: opID=242de72d-50-ba0c seq=602267: Receiving GuestOps.ListProcesses request.

2019-04-02T11:35:56.138Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=242de72d-50-ba0c seq=602267: Completed GuestOps request.

2019-04-02T11:35:56.151Z| vmx| I125: VigorTransportProcessClientPayload: opID=9f71daa-e1-ba12 seq=602279: Receiving GuestOps.InitiateFileTransferFromGuest request.

2019-04-02T11:35:56.234Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=9f71daa-e1-ba12 seq=602279: Completed GuestOps request.

2019-04-02T11:35:56.437Z| vmx| I125: VigorTransportProcessClientPayload: opID=39b2e7b7-b8-ba18 seq=602291: Receiving GuestOps.InitiateFileTransferFromGuest request.

2019-04-02T11:35:56.586Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=39b2e7b7-b8-ba18 seq=602291: Completed GuestOps request.

2019-04-02T11:35:56.774Z| vmx| I125: VigorTransportProcessClientPayload: opID=4541f03c-56-ba20 seq=602303: Receiving GuestOps.InitiateFileTransferFromGuest request.

2019-04-02T11:35:56.833Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=4541f03c-56-ba20 seq=602303: Completed GuestOps request.

2019-04-02T11:35:57.027Z| vmx| I125: VigorTransportProcessClientPayload: opID=7185c8d4-be-ba28 seq=602331: Receiving GuestOps.DeleteFile request.

2019-04-02T11:35:57.191Z| vcpu-0| I125: VigorTransport_ServerSendResponse opID=7185c8d4-be-ba28 seq=602331: Completed GuestOps request.

Seems not strange to me.Additional Info:

I'm using the PowerCli Module donwloadable as a package from PSgallery

vmware.powercli                     11.2.0.12780525

0 Kudos
Highlighted
Enthusiast
Enthusiast

Yes same Versions:
vSphere Client version 6.7.0.20000

VMware.PowerCLI                11.2.0.12780525

0 Kudos
Highlighted
User Moderator
User Moderator

If you have the possibility, it could be useful to enable debug logging for the VMware Tools in the guest OS.
See KB1007873


Another question, are you using an embedded PSC or a standalone PSC?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
User Moderator
User Moderator

You might also want to give my Invoke-VMScriptPlus function try.

Curious if that experiences the same issue.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Enthusiast
Enthusiast

Having issues using Invoke-VmSCriptPlus... some errors about an DNS name that does not exist, as the Function is trying to resolve a reverse Lookup entry... and some other errors.
I did not bother yet trying to troubleshoot this at the time. I will try enabling advanced logging next and maybe I come back to using your function again.

0 Kudos
Highlighted
Enthusiast
Enthusiast

I got VMWare.PowerCLI 11.2.0.12483598 but the problem is exactly the same.

0 Kudos
Highlighted
Enthusiast
Enthusiast

I enabled the debug logging...here some lines that got my attention:

2019-04-02T12:49:48.677Z| vcpu-3| I125: CDROM sata0:0: CMD 0xa4 (*UNKNOWN (0xa4)*) FAILED (key 0x5 asc 0x20 ascq 0)

[...]

2019-04-02T12:49:51.430Z| mks| W115: VNCENCODE 1809 failed to allocate VNCBlitDetect

[...]

2019-04-02T12:50:49.992Z| vmx| I125: Guest: toolbox-dnd: Version: build-8068406

2019-04-02T12:50:49.992Z| vcpu-2| W115: GuestRpc: application toolbox-dnd, changing channel 65535 -> 1

2019-04-02T12:50:49.992Z| vcpu-2| I125: GuestRpc: Channel 1, guest application toolbox-dnd.

2019-04-02T12:51:23.598Z| vmx| I125: GuestRpc: Got error for channel 2 connection 2908: Remote disconnected


We are using embedded PSC.

0 Kudos
Highlighted
User Moderator
User Moderator

Are the VMware Tools in the VM the latest version?
Do you see a message to upgrade the tools?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Enthusiast
Enthusiast

I have installed the latest version after discovering the error: Now version 10.2.5.

No Message about updating the tools.

0 Kudos
Highlighted
User Moderator
User Moderator

And any difference with Invoke-VMScript?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Enthusiast
Enthusiast

No, same as before.

0 Kudos
Highlighted
Enthusiast
Enthusiast

LucD​: thanks to your Invoke-VMScriptPlus I was able to find the problem.

Apparently to get the result both your script and the original cmdlet connect to the esx host via ip and not via dns name.

This break the certificate trust ( I changed the default root-ca in the vcenter and the new certificates issued by it do not contain the IP address in the dns alternaticve subject) and unlike your script the Invoke-VMScript doesn't report a good error.

I temporary add this to my script to ignore the certificate problem:

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;

  }

}

"@

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

I guess there is not way to change this behavior?

By the way set the powercli to ignore the certificate problem using "Set-PowerCLIConfiguration -InvalidCertificateAction Ignore" doesn't work

View solution in original post

Highlighted
Enthusiast
Enthusiast

Thank you! Works for me!

0 Kudos