简体   繁体   中英

Calling a powershell script from a powercli script using invoke-vmscript?

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.

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

您必须输入脚本的脚本变量内容,而不是文件名。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM