Private/Get-NSPConditionalAccessMapValue.ps1

function Get-NSPConditionalAccessMapValue {
    <#
    .SYNOPSIS
        Reads a key from a hashtable or a PSCustomObject (JSON loaded under 5.1), returning $null when absent.
    #>

    [CmdletBinding()]
    param(
        $Map,
        [Parameter(Mandatory)][string]$Key
    )

    if ($null -eq $Map) { return $null }
    if ($Map -is [System.Collections.IDictionary]) {
        if ($Map.Contains($Key)) { return $Map[$Key] }
        return $null
    }
    $property = $Map.PSObject.Properties[$Key]
    if ($property) { return $property.Value }
    $null
}