我正在尝试在命令行中运行PowerShell脚本。有人给了我一个例子,它确实有效:
powershell.exe -noexit "& 'c:\Data\ScheduledScripts\ShutdownVM.ps1'"
但问题在于我的PowerShell脚本有输入参数,所以我尝试了一下,但它没有起作用:
powershell.exe -noexit "& 'D:\Work\SQLExecutor.ps1 -gettedServerName "MY-PC" ' "
错误信息如下:
无法将术语“D:\Work\SQLExecutor.ps1 -gettedServerName "MY-PC"”识别为 cmdlet、函数的名称。
我该如何解决这个问题?