将参数传递给powershell脚本

des*_*sto 6 windows parameters powershell cmd

我正在尝试从运行对话框运行一个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'
Run Code Online (Sandbox Code Playgroud)

但是在读取参数时失败了.

.\script.ps1 -title 'Hello world' -msg 'This is a test message'在powershell上运行工作正常.

Nat*_*man 4

-file在脚本路径之前使用:

powershell.exe -noexit -file 'D:\Tasks Scripts\Powershell\script.ps1' etc...
Run Code Online (Sandbox Code Playgroud)