Skip to content

Instantly share code, notes, and snippets.

@ChrisMagnuson
Forked from kyle-herzog/ConvertTo-Boolean.ps1
Last active October 18, 2017 07:47
Show Gist options
  • Save ChrisMagnuson/92ebde76384af02dcc62 to your computer and use it in GitHub Desktop.
Save ChrisMagnuson/92ebde76384af02dcc62 to your computer and use it in GitHub Desktop.
function ConvertTo-Boolean
{
param
(
[Parameter(Mandatory=$false,ValueFromPipeline=$true)][string] $value
)
switch ($value)
{
"y" { return $true; }
"yes" { return $true; }
"true" { return $true; }
"t" { return $true; }
1 { return $true; }
"n" { return $false; }
"no" { return $false; }
"false" { return $false; }
"f" { return $false; }
0 { return $false; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment