How to pass command-line arguments to a PowerShell ps1 file

前端 未结 7 881
Happy的楠姐
Happy的楠姐 2020-12-12 23:21

For years, I have used the cmd/DOS/Windows shell and passed command-line arguments to batch files. For example, I have a file, zuzu.bat and in it,

7条回答
  •  Happy的楠姐
    2020-12-13 00:04

    You may not get "xuxu p1 p2 p3 p4" as it seems. But when you are in PowerShell and you set

    PS > set-executionpolicy Unrestricted -scope currentuser
    

    You can run those scripts like this:

    ./xuxu p1 p2 p3 p4
    

    or

    .\xuxu p1 p2 p3 p4
    

    or

    ./xuxu.ps1 p1 p2 p3 p4
    

    I hope that makes you a bit more comfortable with PowerShell.

提交回复
热议问题