Skip to content
Menu

Entra Connect Stopped Syncing

Reads the tenant's last directory sync time from Microsoft Graph and alerts when it is older than MaxAgeHours or when sync has been turned off. No access to the sync server is needed.

Entra Connect stopped syncing is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Entra Connect stopped syncing. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, 11, Server 2016+, with the app certificate; runs as SYSTEM or a user
NeedsPowerShell 5.1; app registration with Microsoft Graph application permission Organization.Read.All, admin-consented
Read-onlyReads, changes nothing

What It Does

This script is read-only. It signs in as your app registration, with a certificate or a ClientSecret from a secure RMM field, and reads the tenant's organization record from Microsoft Graph. It needs no access to the sync server: this is the view from the cloud. To start a cycle from the server, use invoke-entra-delta-sync.

If the tenant has never been synced, the script ends SKIPPED. If it was synced once and sync is now off, it ALERTS. If sync is on, it ALERTS when the last sync time is missing or older than MaxAgeHours (1 to 720, default 3), and otherwise reports OK with the age in hours. The answer shows the last sync time and the limit.

Password hash sync time and sync error counts are not in this record, so they are not checked. Use test-entra-connect-health on the server for the service, the run results and the version, and get-directory-sync-errors for errors on objects. The script keeps no state, so a second run reads the same record again.

Grant the app Organization.Read.All. With only User.Read the sync properties come back empty, which can look like a tenant that was never synced.

Before You Run It

  • Create an app registration with Organization.Read.All and grant admin consent.
  • Put the app's certificate, with its private key, on the computer that runs the script, or use a ClientSecret from a secure RMM field.
  • Keep MaxAgeHours above your sync interval. The default of 3 hours suits the usual 30 minute cycle.
  • Schedule it in your RMM and alert on exit 1.
  • Pair it with test-entra-connect-health on the sync server for the service and connector view.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 10 seconds.
  • Example answer: "Directory sync: last sync 5 h ago (2026-11-18T09:12:00Z); limit 3 h"
  • Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.

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 Application (client) ID of the app registration that holds the Graph permissions. Required.
  • CertificateThumbprint: Thumbprint of the app's certificate (private key in LocalMachine\My or CurrentUser\My). Preferred. When empty, the app secret is read from the environment variable ClientSecret (a secure/hidden RMM field; never an argument).
  • MaxAgeHours: Alert when the last sync is older than this many hours. Whole number, 1 to 720. Default 3.

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.

The Script

test-entra-connect-sync.ps1 · 962 lines · 53.7 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.