TryParse should work as long as you use ref and declare the variable first:
$out = $null
if ([bool]::TryParse($a, [ref]$out)) {
# parsed to a boolean
Write-Host "Value: $out"
} else {
Write-Host "Input is not boolean: $a"
}
TryParse should work as long as you use ref and declare the variable first:
$out = $null
if ([bool]::TryParse($a, [ref]$out)) {
# parsed to a boolean
Write-Host "Value: $out"
} else {
Write-Host "Input is not boolean: $a"
}