我试图在cmd命令行中运行PowerShell脚本。有人给我一个例子,它的工作原理:如何在CMD中运行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的名称,函数,
等待帮助!谢谢!
您确定要使用-noexit吗?这意味着当你的脚本完成时,shell会挂起,可能会阻塞CMD中批处理文件的执行。 – x0n 2013-05-08 15:56:09