VMware Cloud Community
SebastianReitte
Enthusiast
Enthusiast
Jump to solution

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

(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!

36 Replies
LucD
Leadership
Leadership
Jump to solution

Great find.
I'll try to update my Invoke-VMScriptPlus to cope with that, or introduce it as an option.


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

MSpriya
Contributor
Contributor
Jump to solution

Hi,

Probably too late to post here.

I am facing the same issue. This post was helpful.

I have tried the workarounds suggested, still Invoke-VMScript command invocation is failing with the same error.

What else could cause this issue, apart from invalid certificate?

I have also verified that the script text is getting executed on the VM, but only the results of the command are not propagated back to the caller.

PowerCLI version used is 11.3

One more point to note is that the setup has distributed virtual switch and portgroups configured.

Any help is much appreciated.

Thanks,

Priya

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you try with my Invoke-VMScriptPlus function?
With the Verbose switch, that function tends to provide more feedback.


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

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

Hi @LucD , thank you for pointing to the script. 

Please find the output of Invoke-VMScriptPlus script execution below:

PS C:\Users\Administrator\Desktop> .\Invoke-VMScriptPlus.ps1
VERBOSE: 09/11/2020 5:39:28 PM Get-View Finished execution
VERBOSE: 09/11/2020 5:39:28 PM Get-View Finished execution
VERBOSE: 09/11/2020 5:39:28 PM Get-View Finished execution
VERBOSE: 09/11/2020 5:39:28 PM Get-View Finished execution
VERBOSE: No GuestOSType value provided. Trying to determine now.
VERBOSE: It's a Windows guest OS
VERBOSE: Created temp folder in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_3368vmware40
VERBOSE: Created temp script file in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_3368vmware40\Administrator_3368vmware239.cmd
VERBOSE: Created temp output file in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_3368vmware40\Administrator_3368_outputvmware241
VERBOSE: Copying Data to C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_3368vmware40\Administrator_3368vmware239.cmd
VERBOSE: PUT https://<IPAddress>/guestFile?id=54&token=86d6f91a-7e18-819d-01d7-8935c8e0b02559 with 8-byte payload
Invoke-WebRequest: C:\Users\Administrator\Desktop\Invoke-VMScriptPlus.ps1:255
Line |
255 | $copyResult = Invoke-WebRequest @sWeb
| ~~~~~~~~~~~~~~~~~~~~~~~
| A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to
| respond.
Exception: C:\Users\Administrator\Desktop\Invoke-VMScriptPlus.ps1:258
Line |
258 | Throw "ScripText copy failed!`rStatus $($copyResult.StatusCode)`r$(($ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ScripText copy failed!Status
PS C:\Users\Administrator\Desktop>

 

Any idea on what could be the issue here ?

Reply
0 Kudos
vjiayvakacharla
Contributor
Contributor
Jump to solution

 

 

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

Hi @LucD , do you have any idea on this issue? 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

This could be a certificate issue.
Did you try Invoke-VMScriptPlus with the NoIPinCert switch?


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

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

No, I havent tried running Invoke-VMScriptPlus with -NoIPinCert switch but have done the following:

1. Set the powercli invalid certificate action to ignore

2. made sure there are no invalid certificates used 

Could it still be certificate issue? 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, the transfer of files is done directly to the ESXi node on which the VM is running.
When the certificate on the ESXi does not have the IP SAN, this can also cause this issue.


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

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

@LucD , thanks for the information.


>> When the certificate on the ESXi does not have the IP SAN, this can also cause this issue.

So this we will be able to identify using the -NoIPinCert switch with Invoke-VMScriptPlus script right? 

 
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Correct, the function will then covert the IP in the URI to an FQDN


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

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

Hi @LucD , The certificate contains FQDN instead of IP address in SAN field. But still Invoke-VMScriptPlus script is failing with same error if we use -NoIPinCert switch. I also tried with -SkipCertificateCheck option too. 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you use the Verbose option?
That might provide additional info on the issue.


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

Reply
0 Kudos
MSpriya
Contributor
Contributor
Jump to solution

Yes I used verbose option as well. The error is same as earlier runs: 

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to
| respond.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

There should be much more information when you use the Verbose switch.
It will allow to determine where the issue occurs


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

Reply
0 Kudos
sfumn
Contributor
Contributor
Jump to solution

Thank you very much gmslsupport. your solution works. You are my saviour.

Reply
0 Kudos
Krishna1981
Contributor
Contributor
Jump to solution

Please provide the solution

Reply
0 Kudos