initial Commit
This commit is contained in:
33
Private/ConvertTo-ConfigurationDataExpressionBoolean.ps1
Normal file
33
Private/ConvertTo-ConfigurationDataExpressionBoolean.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
function ConvertTo-ConfigurationDataExpressionBoolean {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[AllowNull()]
|
||||
$Value
|
||||
)
|
||||
|
||||
if($null -eq $Value){
|
||||
return $false
|
||||
}
|
||||
|
||||
if($Value -is [bool]){
|
||||
return $Value
|
||||
}
|
||||
|
||||
if($Value -is [int]){
|
||||
return $Value -ne 0
|
||||
}
|
||||
|
||||
if($Value -is [string]){
|
||||
if($Value -match "^(?i:true|false)$"){
|
||||
return [bool]::Parse($Value)
|
||||
}
|
||||
|
||||
return $Value.Length -gt 0
|
||||
}
|
||||
|
||||
if($Value -is [System.Array]){
|
||||
return @($Value).Count -gt 0
|
||||
}
|
||||
|
||||
return [bool]$Value
|
||||
}
|
||||
Reference in New Issue
Block a user