Skip to content
Menu

OneDrive Not Syncing - Health and Known Folder Move Monitor

Probes OneDrive in the signed-in user's session and alerts when an account is signed in but OneDrive is not running, or required folders are not redirected into OneDrive.

OneDrive not syncing - health and Known Folder Move monitor 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 OneDrive not syncing - health and Known Folder Move monitor. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, a signed-in user (the probe runs in their session)
Read-onlyReads, changes nothing

What It Does

The script is read-only. It looks at OneDrive as the signed-in user sees it, by running a short read-only probe in that user's session, using the user's own registry and folders and not SYSTEM's. It checks whether OneDrive.exe is running in the user's session and which OneDrive registry account entries have an email address. It shows the folder and configured tenant ID when those values are available. It reads where Desktop, Documents and Pictures live and whether each sits inside a OneDrive folder, which is Known Folder Move.

It also shows the diagnostics log's file time, if it exists, and the last SyncProgressState number it finds in the last 400 lines. It is information only and never raises an alert, because OneDrive does not document the number.

It alerts when an account is signed in but OneDrive is not running, or when RequireKfm is true and one of KfmFolders is not redirected into OneDrive, including when no account is signed in at all. It is SKIPPED when nobody is signed in, or when RequireKfm is false and no OneDrive account is set up for the user.

It checks the console user. On a PC where several people are signed in, such as a terminal server, only that session is looked at.

Before You Run It

  • Set RequireKfm to true only where the client has agreed to redirect folders into OneDrive.
  • Choose KfmFolders from Desktop, Documents and Pictures. The default is Desktop and Documents.
  • Know that it is skipped when nobody is signed in, because the probe runs in their session.
  • Do not treat the sync progress number as a status. It is shown for information only.

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 30 seconds.
  • Example answer: "OneDrive running; 1 account ([account sign-in]); Known Folder Move: Desktop, Documents in OneDrive"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

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.

  • RequireKfm: true to alert when a folder in KfmFolders is not inside the user's OneDrive folder. Default false.
  • KfmFolders: Folders that must be redirected when RequireKfm is true: any of Desktop, Documents, Pictures, separated by commas. Default Desktop,Documents.

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-onedrive-sync.ps1 · 857 lines · 44.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.