Private/Get-NSPConditionalAccessTravelEntry.ps1

function Get-NSPConditionalAccessTravelEntry {
    <#
    .SYNOPSIS
        The tenant profile's travel entries with their status and generated policy Id.
    .DESCRIPTION
        Status:
          - Active: a country entry, or a trip whose EndDate is today or later.
          - Expired: a trip whose EndDate has passed.
          - RetireRequested: the operator asked to retire it (Remove-NSPConditionalAccessTravel).
        Expired and RetireRequested entries get no travel policy definition; the planner retires
        their policy in the safe order instead (see New-NSPConditionalAccessDeploymentPlan).
        Policy Ids: NSP-TRAVEL-<ISO>-01 for a country, NSP-TRAVEL-TRIP-<NN> for a trip.
        ImportedPolicyId: the live policy Import-NSPConditionalAccessTravel found for the entry.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]$TenantProfile,
        [datetime]$Today = (Get-Date).Date
    )

    $entries = Get-NSPConditionalAccessMapValue (Get-NSPConditionalAccessMapValue $TenantProfile 'Travel') 'Entries'
    if ($null -eq $entries) { return }
    $keys = if ($entries -is [System.Collections.IDictionary]) { @($entries.Keys) } else { @($entries.PSObject.Properties.Name) }
    foreach ($key in ($keys | Sort-Object)) {
        $entry = Get-NSPConditionalAccessMapValue $entries $key
        $kind = Get-NSPConditionalAccessMapValue $entry 'Kind'
        $endDate = Get-NSPConditionalAccessMapValue $entry 'EndDate'
        $status = if (Get-NSPConditionalAccessMapValue $entry 'RetireRequested') { 'RetireRequested' }
        elseif ($kind -eq 'Trip' -and $endDate -and ([datetime]$endDate).Date -lt $Today) { 'Expired' }
        else { 'Active' }
        [pscustomobject]@{
            Key = $key
            Kind = $kind
            Name = Get-NSPConditionalAccessMapValue $entry 'Name'
            Countries = @(Get-NSPConditionalAccessMapValue $entry 'Countries' | Where-Object { $_ })
            EndDate = $endDate
            Status = $status
            Ids = @(Get-NSPConditionalAccessMapValue $entry 'Ids' | Where-Object { $_ })
            DefaultName = Get-NSPConditionalAccessMapValue $entry 'DefaultName'
            ImportedPolicyId = Get-NSPConditionalAccessMapValue $entry 'ImportedPolicyId'
            PolicyId = if ($kind -eq 'Trip') { "NSP-TRAVEL-$key" } else { "NSP-TRAVEL-$key-01" }
        }
    }
}