Before you start

Take an inventory and a backup

Count what sync put in the old tenant and save a copy. You check against these numbers at every later step.

10 minutesRead-only

Install the Graph modules

PowerShell
Install-Module Microsoft.Graph.Authentication, Microsoft.Graph.Users, Microsoft.Graph.Groups, `
  Microsoft.Graph.Identity.DirectoryManagement, Microsoft.Graph.Applications -Scope CurrentUser -Repository PSGallery

Count what sync created

PowerShell
Connect-MgGraph -TenantId old.contoso.com -Scopes "User.Read.All","Group.Read.All","Directory.Read.All","Domain.Read.All" -NoWelcome
(Get-MgOrganization).DisplayName    # make sure this is the OLD tenant

Get-MgUser -Filter "onPremisesSyncEnabled eq true" -All -ConsistencyLevel eventual -CountVariable n |
  Select-Object UserPrincipalName | Sort-Object UserPrincipalName
"$n synced users"
Get-MgGroup -Filter "onPremisesSyncEnabled eq true" -All -ConsistencyLevel eventual -CountVariable g | Out-Null; "$g synced groups"
(Get-MgDomainNameReference -DomainId "lab.contoso.com" -All | Measure-Object).Count    # objects using the old domain

Expect your synced users plus one extra: ADToAADSyncServiceAccount, the agent's own account.

Back them up

PowerShell
Get-MgUser -Filter "onPremisesSyncEnabled eq true" -All -ConsistencyLevel eventual -CountVariable n `
  -Property Id,UserPrincipalName,DisplayName,OnPremisesImmutableId,AssignedLicenses |
  Select-Object UserPrincipalName, DisplayName, Id, OnPremisesImmutableId,
    @{n='Licences';e={($_.AssignedLicenses.SkuId) -join ';'}} |
  Export-Csv "$env:USERPROFILE\Desktop\old-tenant-synced-users-$(Get-Date -f yyyyMMdd).csv" -NoTypeInformation
Your progress is kept in this browser only.