What It Does
The script signs in to one tenant as your app and reads sync provisioning errors for users, groups and contacts. It also requests unresolved service provisioning errors. If Graph rejects that request for a collection, it warns and reads only the sync errors for that collection.
When Entra assigns a temporary UPN or removes a duplicate address, the error row shows the object that lost the value. ConflictsWith shows the lookup result for the object that holds it. The script tries up to 100 lookups, keyed by property, value and object. Failed, unmatched and omitted lookups are marked.
Fix the conflicting value in Active Directory or on the other object, then check again after sync. The script makes no changes.
Partly tested: it ran against a tenant synced by Entra Connect, and its conflict lookups were run against real objects, but Entra never published an error there, so a row built from a real error has not been seen yet.
Before You Run It
- Create an app registration in the client tenant with the Graph application permissions User.Read.All, Group.Read.All and OrgContact.Read.All, and give admin consent.
- Use it in tenants synced from Active Directory by Entra Connect or Cloud Sync; a cloud-only tenant has nothing to report.
Type and Risk
- Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 5 minutes.
- Example answer: "Directory sync errors: 5 object(s) with 6 error(s): 4 sync (UPN or proxy address conflicts), 2 service"
- Partly tested before listing: run with Windows PowerShell 5.1 against a Microsoft 365 test tenant as far as it allowed, and compared with tested scripts. The help says which part is unproven.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- TenantId: The client tenant: its ID (a GUID) or a domain such as contoso.onmicrosoft.com. Required.
- ClientId: The app registration's Application (client) ID, a GUID. Required.
- CertificateThumbprint: Thumbprint (40 hex characters) of the app's certificate with its private key in LocalMachine\My or CurrentUser\My on this computer. Preferred. When empty, the secret is read from the environment variable ClientSecret (a secure RMM field).
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.