I\'m trying to convert an argument of my PowerShell script to a boolean value. This line
[System.Convert]::ToBoolean($a)
works fine as long
TryParse should work as long as you use ref and declare the variable first:
TryParse
ref
$out = $null if ([bool]::TryParse($a, [ref]$out)) { # parsed to a boolean Write-Host "Value: $out" } else { Write-Host "Input is not boolean: $a" }