Private/Helper/Convert-BDContains.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Convert-BDContains {
    [CmdletBinding()]
    [OutputType([hashtable])]
    param (
        [Parameter(Mandatory = $false)] $Contains,
        [Parameter(Mandatory = $false)] [string] $DefaultProperty = "Title"
    )

    process {
        if ($Contains.psObject.TypeNames -contains "System.Collections.Hashtable") {
            Return $Contains
        }
        elseif ($Contains.psObject.TypeNames -contains "System.String") {
            Return @{
                $DefaultProperty = $Contains
            }
        }
        else {
            Return $null
        }
    }
}