Private/Get-NSPEntraPairingProxyReview.ps1

function Get-NSPEntraPairingProxyReview {
    [CmdletBinding()]
    param([Parameter(Mandatory)]$CloudUser,[Parameter(Mandatory)]$ADUser,
        [string[]]$CopyType = @('SMTP','SIP','X500'))
    $hasProperty = if ($CloudUser -is [Collections.IDictionary]) { $CloudUser.Contains('proxyAddresses') }
        else { $null -ne $CloudUser.PSObject.Properties['proxyAddresses'] }
    if (-not $hasProperty -or $null -eq $CloudUser.proxyAddresses) {
        throw 'Cloud proxyAddresses were not captured. Refresh the full inventory before address preparation.'
    }
    foreach ($proxy in @($CloudUser.proxyAddresses)) {
        $reason = ''
        $disposition = 'NeedsReview'
        $type = ''
        if ($proxy -is [string] -and $proxy -match '^([A-Za-z][A-Za-z0-9]*):([^\r\n]+)\z' -and $proxy.IndexOf([char]0) -lt 0) {
            $type = $Matches[1].ToUpperInvariant()
            if (@($ADUser.ProxyAddresses) -icontains $proxy) { $disposition = 'PresentInAD' }
            elseif ($type -eq 'SMTP' -and $proxy -imatch '@[^@]*\.(onmicrosoft\.com|microsoftonline\.com)$') {
                $disposition = 'CloudManaged'; $reason = 'Reserved routing domain; retain in cloud, not a proposed AD addition.'
            } elseif ($type -in $CopyType) { $disposition = 'AddToAD' }
            elseif ($type -eq 'SPO') { $disposition = 'CloudManaged'; $reason = 'Opaque service identifier; no automatic on-premises copy.' }
            else { $reason = 'Unselected proxy protocol requires an explicit preservation decision.' }
        } else { $reason = 'Malformed cloud proxy requires review; it is not silently discarded.' }
        [pscustomobject]@{Address=[string]$proxy;Type=$type;Disposition=$disposition;Reason=$reason}
    }
}