Local Admin Drift
Intune remediation scripts that remove unexpected local admins, show who added them, and warn when the same fix keeps coming back. Runs without Windows Enterprise too.
What it does
- Lists the local Administrators group and flags anyone who isn't on your allow list. The built-in Administrator, Domain Admins and Entra roles added at join are always allowed
- Reads event 4732 to show who added the account. SYSTEM means a service, scheduled task or installer
- Counts its own fixes over the last 7 days and says Keeps coming back: find the cause or move this to a policy after 3
- Removes the extra members, logs each removal and writes event 1001 to the Application log
- Starts as a dry run. Nothing is removed until you set
$WhatIfto$false - Logs every check to
C:\ProgramData\Atliso\LocalAdminDrift.log
Configuration
You edit one block, in the detection and remediation scripts or once in the installer:
# ===== CONFIG =====
$AllowedMembers = @('it-admin') # accounts that may stay in local Administrators (names, not SIDs)
$WhatIf = $true # $true = log what would be removed, change nothing. $false = remove.
$IntervalHours = 1 # installer only: how often the check runsDeploy as an Intune Remediation
Needs Windows Enterprise E3 or E5, Education A3 or A5, or VDA for the device users.
- In the Intune admin center: Devices > Scripts and remediations > Remediations > Create.
- Upload
Detect-LocalAdminDrift.ps1as the detection script andRemediate-LocalAdminDrift.ps1as the remediation script. - Run as SYSTEM in the 64-bit PowerShell host, on an hourly or daily schedule.
Deploy without Windows Enterprise
On Business Premium, upload Install-LocalAdminDrift.ps1 as a platform script instead. It carries all three scripts, locks their folder to SYSTEM and Administrators, and registers an hourly scheduled task that detects, fixes and confirms.
Full walkthrough with screenshots: Intune Remediations: when the same fix keeps coming back
Version history
Scripts are checked against each month's Windows and Intune changes and patched when something breaks. Every version stays available: if a newer one misbehaves in your environment, use the one before it and reply to any Atliso email to tell me.
v1.0.0Latest
Download v1.0.0 from GitHubInitial public release. MIT licensed.
- Detect-LocalAdminDrift.ps1 and Remediate-LocalAdminDrift.ps1: an Intune Remediation pair for unexpected local admins, with who added them (event 4732) and a warning when the same fix keeps coming back.
- Install-LocalAdminDrift.ps1: one platform script for tenants without Windows Enterprise. Installs all three scripts and an hourly SYSTEM task.
- Ships as a dry run. Set $WhatIf = $false once the log lists only accounts you want gone.
Tested on Windows 11 Pro with Windows PowerShell 5.1. Guide: https://atliso.com/blog/intune-remediations-recurring-issues
Get Local Admin Drift
Free and MIT licensed. Drop your email and the vault unlocks straight away with the tested scripts and installer, plus updates when Microsoft changes something. No spam.