The reason I do it
I am trying to set a token in a file that I have. The content of the token is 1 line in the file, and this is the string value $token=$false
Simplified verification code
When I try to convert this token to a bool value, I have some problems. Therefore, I wrote test code and found that I could not convert the string to a bool value.
[String]$strValue = "$false" [Bool]$boolValue = $strValue Write-Host '$boolValue =' $boolValue
This gives the following error ...
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:2 char:17 + [Bool]$boolValue <<<< = $strValue
As you can see, I use the value $false
, as this suggests an error message, but it does not accept it. Any ideas?
source share