我试图从运行对话框(将用作计划任务)运行PowerShell脚本,并且遇到麻烦传递参数。将参数传递给powershell脚本
该脚本将包含两个名为title和msg的参数。 该脚本位于:D:\Tasks Scripts\Powershell\script.ps1
这就是我想要做的事:
powershell.exe -noexit 'D:\Tasks Scripts\Powershell\script.ps1' -title 'Hello world' -msg 'This is a test message'
但它无法在阅读的参数。
在powershell上运行.\script.ps1 -title 'Hello world' -msg 'This is a test message'
工作正常。
使用-command选中此SO回答-http://stackoverflow.com/questions/12691781/scheduled-task-for-powershell-script-with -string阵列面值ameter – Mitul
如果您能告诉我们“它失败”的含义,这将有所帮助。如果有错误消息,请引用错误消息,或者告诉我们发生了什么以及您期望发生什么。 –