How to run PowerShell in CMD

后端 未结 3 671
抹茶落季
抹茶落季 2020-12-05 04:16

I\'m trying to run a PowerShell script inside cmd command line. Someone gave me an example and it worked:

powershell.exe -noexit \"& \'c:\\Data\\Schedule         


        
3条回答
  •  情歌与酒
    2020-12-05 04:29

    You need to separate the arguments from the file path:

    powershell.exe -noexit "& 'D:\Work\SQLExecutor.ps1 ' -gettedServerName 'MY-PC'"
    

    Another option that may ease the syntax using the File parameter and positional parameters:

    powershell.exe -noexit -file "D:\Work\SQLExecutor.ps1" "MY-PC"
    

提交回复
热议问题