vmware / powerclicore

PowerCLI Core Dockerfile
Apache License 2.0
100 stars 47 forks source link

Error when running Invoke-VMScript #12

Closed dandunckelman closed 6 years ago

dandunckelman commented 7 years ago

Summary

The Invoke-VMScript command results in an error.

How I start the container

#!/bin/bash
SCRIPT="Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:\$false; \
  bin/move-vms-on-port-group.ps1 -PortGroupName @option.port_group_name@"

docker run --rm -i \
  --dns=DNS_SERVER_IP \
  --entrypoint="/usr/bin/powershell" \
  --workdir /tmp \
  -v SCRIPT_DIR:/tmp \
  vmware/powerclicore \
  "$SCRIPT"

Summary of my script

Connect-VIServer VCENTER_HOST -User VCENTER_USER -Password VCENTER_PASSWORD
$vm = Get-VM -Id VM_ID
$out = Invoke-VMScript -VM $vm -ScriptText "ping -c 10 8.8.8.8" -GuestUser root -GuestPassword PASSWORD -ScriptType Bash
Write-Host "Ping output: $out"

Expected Results

When I run it locally on a Windows machine (where powerCLI is installed...not a Docker container), I get this:

Ping output: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=6.06 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=6.07 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=6.03 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=6.04 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=6.06 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=56 time=6.05 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=56 time=6.12 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=56 time=6.03 ms
64 bytes from 8.8.8.8: icmp_seq=9 ttl=56 time=6.08 ms
64 bytes from 8.8.8.8: icmp_seq=10 ttl=56 time=6.03 ms

--- 8.8.8.8 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9016ms
rtt min/avg/max/mdev = 6.038/6.063/6.120/0.042 ms

Actual Results

Invoke-VMScript : 08/07/2017 21:10:44   Invoke-VMScript     An error occurred while sending the request.

At /tmp/lib/vcenter.ps1:294 char:12
+     $out = Invoke-VMScript -VM $vm -ScriptText $ping -GuestUser $gues ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], ViError
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,
                               VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Ping output: 

Please let me know if I can provide any more info to help.

Thanks

zhang-shengping commented 6 years ago

I have the exactly same error, anyone knows why?

` PS /powershell> Invoke-VMScript -VM $vm -ScriptType bash -ScriptText "ls" -GuestUser root -GuestPassword Passw0rd Invoke-VMScript : 02/26/2018 02:52:16 Invoke-VMScript An error occurred while sending the request. At line:1 char:1

` PS /powershell> Invoke-VMScript -VM $vm -ScriptType bash -ScriptText "ls" -GuestUser root -GuestPassword Passw0rd

ScriptOutput

anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music Pictures Public Templates Videos vmtool-installation.log

` anyone knows why? please help

jakerobinson commented 6 years ago

For PowerCLI issues, please open an SR through https://my.vmware.com or ask the community at https://vmware.com/go/powercli