Functions/Data/Test-Logic.ps1
Function Test-Logic { [CmdletBinding()] Param ( # Value to check [Parameter(Mandatory=$true)] [AllowEmptyString()] [AllowNull()] $Value, # Baseline value to evaluate against [Parameter(Mandatory=$true)] [AllowEmptyString()] [AllowNull()] $ReferenceValue, # Type of Logic Rule [Parameter(Mandatory=$true)] [ValidateSet("LIKE","NOTLIKE","IN","EQ","NE","BT","BT-LE","BT-GE","BT-BE","GT","GE","LT","LE")] [String] $Type ) switch ($Type) { "LIKE" {if ($Value -like $ReferenceValue){$true}else{$false}} "NOTLIKE" {if ($Value -notlike $ReferenceValue){$true}else{$false}} "IN" {if ($Value -in $ReferenceValue){$true}else{$false}} "EQ" {if ($Value -eq $ReferenceValue){$true}else{$false}} "NE" {if ($Value -ne $ReferenceValue){$true}else{$false}} "GT" {if ($Value -gt $ReferenceValue){$true}else{$false}} "GE" {if ($Value -ge $ReferenceValue){$true}else{$false}} "LT" {if ($Value -lt $ReferenceValue){$true}else{$false}} "LE" {if ($Value -le $ReferenceValue){$true}else{$false}} "BT" {if (($Value -gt $ReferenceValue[0]) -and ($Value -lt $ReferenceValue[1])){$true}else{$false}} "BT-LE" {if (($Value -gt $ReferenceValue[0]) -and ($Value -le $ReferenceValue[1])){$true}else{$false}} "BT-GE" {if (($Value -ge $ReferenceValue[0]) -and ($Value -lt $ReferenceValue[1])){$true}else{$false}} "BT-BE" {if (($Value -ge $ReferenceValue[0]) -and ($Value -le $ReferenceValue[1])){$true}else{$false}} } } |