Get-OrElse.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function Get-OrElse {
    [CmdletBinding()]
    Param(
        [Parameter(ValueFromPipeline = $True)]
        [Object]$Value,

        [Parameter(Mandatory = $True)]
        [Object]$Default
    )
    if ([string]::IsNullOrEmpty($Value)) {
        $Default
    } else {
        $Value
    }
}