I just upgraded to VI Toolkit 1.5 and I was trying out Invoke-VMScript but with no success.
I was wondering what is required to run this command on my machine and the guest machine. From what I can find it requires Powershell on both machines and the VI tool kit on the host but is it required within the guest as well? Also do I need to run a specific version of Powershell?
A thread listing the requirements would be great. Here is a start
Required to run Invoke-VMScript:
-Host running the Invoke command
Minimum Powershell version
VI Toolkit version: 1.5
Level of -hostuser access
-Guest recieving the Invoke-VMScript
Minimum Powershell version:
VI toolkit required?
Level of -guestuser access
Thanks!
Afaik these are the requirements on both sides:
1) Machine where you run Invoke-VMScript
- PowerShell v1 or v2 CTP3 (haven't tested with the other v2 previews)
- VITK v1.5 build 142961
2) The guest where you execute the script
- up-to-date version of the VMware Tools
- PowerShell v1 or v2 CTP3 (haven't tested with the other v2 previews)
At first I was confused by the -HostUser parameter.
This is not an account defined on the VC but an account on the ESX server (the hyper-visor) !
I use an account that is in the same groups as root but doesn't have UID=0.
At this moment I don't know to which groups the -HostUser should at least belong.
A simple example with the "dir" command:
get-vm <VM-name> | ` Invoke-VMScript -ScriptText "dir" -HostUser <ESX-account> -HostPassword <ESX-password> -GuestUser <guest-account> -GuestPassword <guest-password>
For the -GuestUser you can give:
1) a local account on the machine (with the required permissions of course)
2) a domain account (if the guest is in a domain) in the formats:
a) "account" (provided the guest is in the same domain as the host from which you run the Invoke-VMScript cmdlet ==> this requires further investigation or clarification)
b) "domain\account"
And don't forget that Carter made a great video on the Invoke-VMScript cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm getting: The method or operation is not implemented.
Get-VM -name "Windows XP" | Invoke-VMScript -ScriptText "Get-Process"
Or this one in another VM
$vm = Get-VM -name "DC.NTPRO.LOCAL"
Invoke-VMScript -VM $vm -ScriptText "Dir"
15-2-2009 21:03:18 Invoke-VMScript 3DA179B6-0EE4-42DD-B8C8-2D5BABA61BB4 While performing operation 'Connect to host service 'https://192.168.178.251/sdk' at port 902' the following error occured: 'The specified service provider was not found'
At :line:8 char:0
Invoke-VMScript -VM $vm -ScriptText "Dir"
Eric, you are passing the -Hostuser and -Guestuser on the command I suspect ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
@LucD22 Fixed the problem, had to to some un-install and install actions... Please don't ask me what but it ends with 1.5 :-0
Hi everyone,
Here's my attempt at a definitive list:
VI toolkit required 1.5
Level of access:
Read access to the VM including folder. (you need to be able to run Get-VM after all)
Virtual Machine.Interaction.Console Interaction privilege
Windows guest with up-to-date tools
Windows PowerShell installed within the Windows guest
Network connectivity to the ESX system hosting the VM on port 902
If I've missed anything please let me know. I've asked to get the docs updated with this info.
As time goes on some of these requirements will go away or change. Look for the requirements around Windows guests and PowerShell within the guest to go away first. If you're impatient (like me) check out the VIX blog for a way to run scripts on Linux and on Windows guests without PowerShell.
I had the same issue, to resolve it on my system required installing the lastest version of the VIX SDK - from .
I'm guessing I had an older version installed already from WS 6.5 (or possibly another VMware product), so the VITK 1.5 installer detected VIX was already installed, but didn't check to see if it was the appropriate version.
I'm guessing I had an older version installed already from WS 6.5 (or possibly another VMware product), so the VITK 1.5 installer detected VIX was already installed, but didn't check to see if it was the appropriate version.
Yes, this is a bug. To see if you have the right version of VIX installed, run this:
& "$env:programfiles\vmware\vmware vix\vmrun.exe" | select -first 2
from a PowerShell window.
You should see this output:
vmrun version 2.0.0 build-127388
Just checked I'm running "vmrun version 6.5.1 build-126130"
Carter,
I'm running
Invoke-VMScript -VM $vm -ScriptText "Get-Process" -GuestUser $vmUser -GuestPassword $vmPswd -HostUser $esxUser -HostPassword $esxPswd
host user is root guest user is administrator but i get no output returned.
i've ran
& "$env:programfiles\vmware\vmware vix\vmrun.exe" | select -first 2
and get
vmrun version 6.5.1 build-126130
so I downloaded the latest version of VIX and installed it still showed as build-126130. Tried re-install vi toolit 1.5 still the same any ideas?
cheers
I just had the same issue yesterday. I had to reboot after installing PowerShell in my guest OS before it would return data. Also, make sure you change the default Execution Policy on your guest.
"Set-ExecutionPolicy RemoteSigned"
Scott
fantastic - reboot did the trick thanks Scott!
A reboot shouldn't be necessary -- sounds like a bug.
HI,
i'm trying to use invoke-vmscript again having had it working before but now get the same error as Erik above:
Invoke-VMScript 3DA179B6-0EE4-42DD-B8C8-2D5BABA61BB4 While performing operation 'Connect to host service 'https://HostServer/sdk' at port 902' the following error occured: 'The specified service provider was not found'
We have updated our hosts but that is the only thing that has changed. VMtools are upto date
I've re-installed powercli.
any ideas?
thanks
When I had this problem and everything else looked fine, I downloaded VIX 1.6.2 and installed it. The problem went away. Do you have Workstation installed on the machine that you're using to kick off the script?
Sometimes, Invoke-VMScript doesn't work when you are connected to the ESX using the hostname. Try to connect using the IP address before using Invoke-VMScript.
I had the same problem when using Invoke-VMScript ( Invoke-VMScript 3DA179B6-0EE4-42DD-B8C8-2D5BABA61BB4 While performing
operation 'Connect to host service 'https://HostServer/sdk' at port
902' the following error occured: 'The specified service provider was
not found' ). Invoke-VMScript only works when I am connected to the host by using its IP address (not the hostname). I think it's a bug.