How to pass boolean values to a PowerShell script from a command prompt

前端 未结 10 2860
逝去的感伤
逝去的感伤 2020-12-08 12:46

I have to invoke a PowerShell script from a batch file. One of the arguments to the script is a boolean value:

C:\\Windows\\System32\\WindowsPowerShell\\v1.0         


        
10条回答
  •  借酒劲吻你
    2020-12-08 13:17

    Running powershell scripts on linux from bash gives the same problem. Solved it almost the same as LarsWA's answer:

    Working:

    pwsh -f ./test.ps1 -bool:true
    

    Not working:

    pwsh -f ./test.ps1 -bool=1
    pwsh -f ./test.ps1 -bool=true
    pwsh -f ./test.ps1 -bool true
    pwsh -f ./test.ps1 {-bool=true}
    pwsh -f ./test.ps1 -bool=$true
    pwsh -f ./test.ps1 -bool=\$true
    pwsh -f ./test.ps1 -bool 1
    pwsh -f ./test.ps1 -bool:1
    

提交回复
热议问题