Public/Get-NSPEntraPairingAddressPlan.ps1

function Get-NSPEntraPairingAddressPlan {
    <#
    .SYNOPSIS
        Previews AD address preparation for the selected pairs using NSP.ActiveDirectory.
    .DESCRIPTION
        Requires a complete forest inventory for collision checks. Returns the AD specialist's
        before/after plans. Does not apply changes or assume a missing forest UPN suffix exists.
        After any Set-NSPADUserAddress -Apply attempt, mark the queue needsRevalidation, retain
        results, read fresh inventories and sync the queue before continuing to hard-match preflight.
    .EXAMPLE
        $plans = Get-NSPEntraPairingAddressPlan -Queue $queue -Inventory $inventory -OldDomain old.example -NewDomain new.example
    #>

    [CmdletBinding()]
    param([Parameter(Mandatory)]$Queue, [Parameter(Mandatory)]$Inventory,
        [Parameter(Mandatory)][string]$OldDomain, [Parameter(Mandatory)][string]$NewDomain,
        [ValidateSet('ReplaceSuffix','SamAccountName','FLast','First.Last','LastF')][string]$Format = 'ReplaceSuffix')
    if ($Queue.needsRevalidation) { throw 'Revalidate the queue before preparing addresses.' }
    if ([string]$Inventory.TenantId -ne [string]$Queue.tenantId) { throw 'Inventory tenant differs from the queue.' }
    if (-not $Inventory.ForestWide) { throw 'Address preparation requires a complete forest inventory (-Forest).' }
    if ($Inventory.ForestName -and [string]$Inventory.ForestName -ine [string]$Queue.forest) { throw 'Inventory forest differs from the queue.' }
    Import-NSPToolkitModule -Name 'NSP.ActiveDirectory' -MinimumVersion '0.1.10'
    if (-not (Get-Command Get-NSPADUserAddressPlan -ErrorAction SilentlyContinue)) { throw 'The AD address-planning API is not available. Use the AD specialist delivery when ready.' }
    $ids = @($Queue.pairs | Where-Object decision -eq 'selected' | ForEach-Object { [guid]$_.adObjectGuid })
    if (-not $ids.Count) { return }
    Get-NSPADUserAddressPlan -User @($Inventory.ADUsers) -Identity $ids -OldDomain $OldDomain -NewDomain $NewDomain -Format $Format
}