Intune Remediation · Starts OneDrive again when a user has quit the sync client
Test in a pilot group before you point this at the fleet. Detection exits 1 to trigger remediation, 0 to stay put.
Detection Script
D
Detect OneDrive not running detection
Exits 1 when the process is missing or the work account key is gone.
›
# Flags a user with OneDrive closed or unconfigured.
if (-not (Get-Process OneDrive -ErrorAction SilentlyContinue)) { exit 1 }
if (-not (Test-Path "HKCU:\Software\Microsoft\OneDrive\Accounts\Business1")) { exit 1 }
exit 0
Remediation Script
R
Start OneDrive in the background remediation
Runs only when detection exits 1.
›
# Launches OneDrive from the per user or machine path.
$p = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"
if (-not (Test-Path $p)) { $p = "$env:ProgramFiles\Microsoft OneDrive\OneDrive.exe" }
Start-Process $p -ArgumentList "/background"
Intune Remediation Settings
Run this script using the logged on credentialsYes