34 lines
580 B
PowerShell
34 lines
580 B
PowerShell
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
|
|
}
|