PowerCli: Invoke-VMScript fails with “An error occurred while sending the request”

Hi,

you want to call some commands in a VM and you got the following error “An error occurred while sending the request”

PowerCLI D:\> Invoke-VMScript -VM (get-vm *myVM*) -GuestUser myUser -GuestPassword 'MySecretPassword' -ScriptText {get-item C:\}
...
invoke-vmscript an error occurred while sending the request
...

This occurs due to a change of the default action how to handle Certificate in newer Powercli Versions.

When you call Invoke-VMscript then, first a connection to the vCenter is made and then a direct connection the ESXi Host where the VM resides.

In the most cases only the vCenter have a valid SSL/TLS Certifcate (signed by an Certification Authority) and the ESXi Hosts has the default configuration with just an selfsigned certificate.

Therefore the connection to the vCenter is allowed but to the connection attempt to the host is rejected by PowerCli.

There are two possibilities.

  • Install also a valid TLS certificate an all ESXi Hosts
  • Or set the “Invalid Certificate Action” to a level which allows establishing a connection to the Host

The default in previous versions of PowerCli is InvalidCertificateAction=unset.

PowerCLI D:\> Get-PowerCLIConfiguration

Scope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout
                                                                                                  Seconds
-----    -----------     ------------------- ------------------------  -------------------------- -------------------
Session  UseSystemProxy  Single              Unset                     True                       300
User                     Single
AllUsers

In newer Versions this is set to InvalidCertificateAction=fail

Solution: Set it to warn , unset or ignore

PowerCLI D:\> Set-PowerCLIConfiguration -InvalidCertificateAction Warn

Michael

Leave a Reply Cancel reply