Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am attempting to execute a .ps1 on multiple VM's using the invoke-VMScript function. Currently I have the code: Invoke-VMScript -ScriptText $script -VM $servername -guestcredential $gcred -hostcredential $hcred and have $script = 'data.ps1' however this returns the error stating that 'data.ps1' is not a valid function or script. Any help is greatly appreciated.

share|improve this question
    
Try passing the full path to data.ps1. It may be looking for it in a different folder than you think. – Nate Hekman Apr 8 '13 at 16:15

I'm not set up to test this, but I would guess that -ScriptText needs to be given the full path to a .ps1 file accessible on the VM.

$script = '"C:\my scripts\data.ps1"'
Invoke-VMScript -ScriptText $script -VM $servername -guestcredential $gcred -hostcredential $hcred
share|improve this answer

You have to put in script variable content of your script, not file name.

share|improve this answer
    
Not true. See vmware.com/support/developer/PowerCLI/PowerCLI51/html/…: "ScriptText: String: Specify the text of the script you want to run. You can also pass to this parameter a string variable containing the path to the script." – Nate Hekman Apr 8 '13 at 16:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.