問題:
I have to invoke a PowerShell script from a batch file. 我必須從批處理文件調用PowerShell腳本。 One of the arguments to the script is a boolean value: 腳本的參數之一是布爾值:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -File .\RunScript.ps1 -Turn 1 -Unify $false
The command fails with the following error: 該命令失敗,並顯示以下錯誤:
Cannot process argument transformation on parameter 'Unify'. Cannot convert value "System.String" to type "System.Boolean", parameters of this type only accept booleans or numbers, use $true, $false, 1 or 0 instead.
At line:0 char:1
+ <<<< <br/>
+ CategoryInfo : InvalidData: (:) [RunScript.ps1], ParentContainsErrorRecordException <br/>
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,RunScript.ps1
As of now I am using a string to boolean conversion inside my script. 到目前爲止,我正在腳本中使用字符串將布爾值轉換爲布爾值。 But how can I pass boolean arguments to PowerShell? 但是如何將布爾參數傳遞給PowerShell?