VMware

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
1 2 Previous Next 17 Replies Last post: Sep 15, 2009 4:51 AM by phsym  

What is required to use Invoke-VMScript posted: Feb 4, 2009 8:47 AM

Click to view Strata's profile Lurker 3 posts since
Dec 18, 2008

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

  1. Minimum Powershell version
  2. VI Toolkit version: 1.5
  3. Level of -hostuser access
-Guest recieving the Invoke-VMScript
  1. Minimum Powershell version:
  2. VI toolkit required?
  3. Level of -guestuser access


Thanks!

Re: What is required to use Invoke-VMScript

1. Feb 4, 2009 1:44 PM in response to: Strata
Click to view LucD's profile Champion 2,430 posts since
Oct 31, 2005
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.

Re: What is required to use Invoke-VMScript

2. Feb 15, 2009 11:40 AM in response to: LucD
Click to view esloof's profile Hot Shot 270 posts since
Nov 11, 2006

I'm getting: The method or operation is not implemented.

Get-VM -name "Windows XP" | Invoke-VMScript -ScriptText "Get-Process"

Re: What is required to use Invoke-VMScript

3. Feb 15, 2009 12:07 PM in response to: esloof
Click to view esloof's profile Hot Shot 270 posts since
Nov 11, 2006

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"

Re: What is required to use Invoke-VMScript

4. Feb 15, 2009 12:30 PM in response to: esloof
Click to view LucD's profile Champion 2,430 posts since
Oct 31, 2005
Eric, you are passing the -Hostuser and -Guestuser on the command I suspect ?

Re: What is required to use Invoke-VMScript

5. Feb 15, 2009 12:58 PM in response to: LucD
Click to view esloof's profile Hot Shot 270 posts since
Nov 11, 2006
@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

Re: What is required to use Invoke-VMScript

6. Feb 17, 2009 12:26 PM in response to: Strata
Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
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.

Re: What is required to use Invoke-VMScript

7. Mar 13, 2009 7:50 AM in response to: esloof
Click to view klich's profile Enthusiast 56 posts since
Jul 25, 2005

I had the same issue, to resolve it on my system required installing the lastest version of the VIX SDK - from http://www.vmware.com/support/developer/vix-api/.

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.


Re: What is required to use Invoke-VMScript

8. Mar 16, 2009 10:29 AM in response to: klich
Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
klich wrote:
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

Re: What is required to use Invoke-VMScript

9. Mar 16, 2009 2:07 PM in response to: c_shanklin
Click to view esloof's profile Hot Shot 270 posts since
Nov 11, 2006
Just checked I'm running "vmrun version 6.5.1 build-126130"

Re: What is required to use Invoke-VMScript

10. May 1, 2009 5:15 AM in response to: c_shanklin
Click to view houghtp's profile Enthusiast 144 posts since
Jan 22, 2008
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

Re: What is required to use Invoke-VMScript

11. May 1, 2009 6:28 AM in response to: houghtp
Click to view scott.herold's profile Enthusiast 24 posts since
Oct 6, 2008

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

Re: What is required to use Invoke-VMScript

12. May 1, 2009 6:53 AM in response to: scott.herold
Click to view houghtp's profile Enthusiast 144 posts since
Jan 22, 2008
fantastic - reboot did the trick thanks Scott!

Re: What is required to use Invoke-VMScript

13. May 1, 2009 8:12 AM in response to: houghtp
Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
A reboot shouldn't be necessary -- sounds like a bug.

Re: What is required to use Invoke-VMScript

14. Jul 16, 2009 8:19 AM in response to: c_shanklin
Click to view houghtp's profile Enthusiast 144 posts since
Jan 22, 2008
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

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities