Reputation: 31
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.
Upvotes: 0
Views: 5902
Reputation: 6657
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
Upvotes: 1
Reputation: 19830
You have to put in script variable content of your script, not file name.
Upvotes: 0