问题:
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?