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
Prior answers are more complete, but if you know that $foo -eq 1, "1", 0, "0", $true, $false... anything that can be coerced to an [int]
Either of the following statements work:
[System.Convert]::ToBoolean([int]$foo)
[System.Convert]::ToBoolean(0 + $foo)
Hope that helps someone that just needs a simple solution.