filter Test-IsNull { <# .SYNOPSIS Simple Null Coalesce Filter .PARAMETER ValueA Value to test for null. Returns this if it's not. .PARAMETER ValueB Value to return if ValueA is null .PARAMETER Strict Correctly handle the case where ValueA is $false. .DESCRIPTION Test if ValueA is null, and return ValueB if so. The legacy version mishandled the case where ValueA is $false. The Strict flag was added as some existing functionality depends on that mishandling. #> param ( $ValueA, $ValueB, [Switch]$Strict ) $logLead = (Get-LogLeadName) if ($Strict) { if (($null -ne $ValueA) -or !([string]::IsNullOrEmpty($valueA))) { $ValueA } else { $ValueB } } else { Write-Warning "$logLead : You are using the old version of this function. Unless you're counting on `$false being equivalent to `$null, you should add the `$Strict flag." if ($null -ne $ValueA -and $ValueA -ne "") { $ValueA } else { $ValueB } } } Set-Alias IsNull Test-IsNull -Force -Scope:Global