Private/Baselines/Reset-BaselineScopeTag.ps1

function Reset-BaselineScopeTag {
    <#
    .SYNOPSIS
        Resets a baseline import body to the built-in Default scope tag
    .DESCRIPTION
        Internal helper function. Scope tag IDs identify objects in a single tenant, so an ID
        carried in an exported template is meaningless (or wrong) in the destination tenant.
        Replaces any top-level roleScopeTagIds value with the built-in Default scope tag ('0'),
        which exists in every tenant. Objects without the property are left untouched.
    .PARAMETER InputObject
        The import body to normalize (modified in place)
    #>

    [CmdletBinding()]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Mutates an in-memory object only')]
    param(
        [Parameter(Mandatory)]
        [PSObject]$InputObject
    )

    if ($InputObject -is [System.Collections.IDictionary]) {
        if ($InputObject.Contains('roleScopeTagIds')) {
            $InputObject['roleScopeTagIds'] = @('0')
        }
        return
    }

    if ($InputObject.PSObject.Properties['roleScopeTagIds']) {
        $InputObject.roleScopeTagIds = @('0')
    }
}