我試圖在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