Skip to content

Intune Remediations: Let PowerShell Fix It Before Dave From Accounts Rings

296 recorded views?

Intune remediations are the closest thing Windows has to a self-cleaning oven. You write one small PowerShell script that checks for a problem and another that fixes it, and Microsoft Intune runs the pair on a schedule until the problem stops coming back.

Without them, the routine is painfully familiar. Dave from accounts rings because his laptop is out of disk space, you remote in and clear out a temp folder stuffed with installers from 2019, and three weeks later he rings again.

This guide covers what Intune remediations are, the licensing and permissions you need, the Intune Management Extension, and my full lab where I clear C:\Temp once it grows past 500MB. It finishes with on-demand runs, logs, a table of other useful examples and a second tested script you can copy.

Never miss a guide: subscribe here and check out my YouTube channel.

The short version (for anyone reading this while the helpdesk queue grows)

  • Intune remediations are script packages: a detection script plus an optional remediation script. The fix only runs when detection exits with code 1.
  • You’ll find them under Devices > Manage devices > Scripts and remediations.
  • Users need Windows Enterprise E3 or E5 (included in Microsoft 365 F3, E3 and E5), Education A3 or A5, or Windows VDA per user. Business Premium on its own generally isn’t enough.
  • Devices must be Microsoft Entra joined or hybrid joined, enrolled or co-managed, and running the Intune Management Extension.
  • Schedule packages once, hourly or daily, or fire one at a single device with Run remediation.
  • Check results in Device status, and on the device in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs.

Prefer to watch? I build the C:\Temp remediation from scratch in this video:

What are Intune remediations?

Intune remediations (previously called Proactive Remediations) are script packages that find and fix common Windows support issues before anyone raises a ticket. Each package holds a detection script, an optional remediation script and a few settings that control how they run.

Detection script resultWhat Intune doesHow it shows in reports
exit 0Nothing. The device is healthyWithout issues
exit 1Runs the remediation script, if the package has oneWith issues, then Issue fixed, Recurred or Failed
Any other exit codeThe remediation script doesn’t runTreated as no issue found

That makes Intune remediations good for ongoing hygiene rather than one-off jobs. Platform scripts run once and move on; remediations keep checking, which is handy when Windows, an app or an over-enthusiastic user quietly undoes your work.

Intune remediations prerequisites and licensing

This is where most people get stuck with Intune remediations, usually just after they’ve written a lovely script.

RequirementDetail
User licenceWindows Enterprise E3 or E5 (included in Microsoft 365 F3, E3 and E5), Windows Education A3 or A5 (included in Microsoft 365 A3 and A5), or Windows Virtual Desktop Access (VDA) per user
Device join typeMicrosoft Entra joined or Microsoft Entra hybrid joined
ManagementEnrolled in Intune running Windows Enterprise, Pro or Education, or co-managed with Configuration Manager
AgentIntune Management Extension, which installs itself when a remediation is assigned. Windows in S mode isn’t supported
Tenant settingWindows license verification turned on (see Step 1)
Admin permissionsDevice configurations permissions to create and assign; Remote tasks/Run Remediation for on-demand runs
Package limitUp to 200 script packages

Gotcha: Microsoft 365 Business Premium includes Intune Plan 1, but its Windows licence is Windows Business (built on Pro), not Windows Enterprise E3. On its own it generally doesn’t meet the licensing for Intune remediations, so talk to your licensing partner about a Windows Enterprise add-on before you promise the boss anything.

How to set up Intune remediations in 7 steps

Step 1: Turn on Windows license verification

Before you can create Intune remediations, Intune wants you to confirm you own the right Windows licences. Until then the Create button stays greyed out, which is Intune’s way of asking for your paperwork.

  1. Sign in to the Microsoft Intune admin centre as an Intune Administrator.
  2. Go to Tenant administration > Connectors and tokens > Windows data.
  3. Turn on “I confirm that my tenant owns one of these licenses”, then save.

This is an attestation for the whole tenant. It doesn’t assign licences to anyone, so make sure the statement is true before you flick the switch.

Step 2: Give yourself the right permissions

For the lab I used the Intune Administrator role, which is fine in a test tenant and far too much for day-to-day work. In production, give the people managing Intune remediations an Intune role instead.

TaskRole or permission
Create, edit and assign remediationsPolicy and Profile Manager, or a custom role with Device configurations Create, Read, Update, Delete, Assign and View Reports
Run a remediation on demandHelp Desk Operator, School Administrator, or a custom role with Remote tasks/Run Remediation plus Organization/Read and Managed devices/Read
Confirm Windows license verificationIntune Administrator
All of the aboveIntune Administrator, ideally eligible through PIM rather than permanent

To assign Intune Administrator, open the Microsoft Entra admin centre, go to Entra ID > Roles & admins, open Intune Administrator, select Add assignments and pick the user. Give it a few minutes, then sign in again. If you use Microsoft Entra PIM, make the assignment eligible.

Step 3: Check the Intune Management Extension is installed

Intune remediations run through the Intune Management Extension (IME), and a device can be fully enrolled without it. The IME installs itself once the user or device is assigned something that needs it, such as a Win32 app, a platform script, a remediation or a custom compliance script.

On the device, open PowerShell and run:

Get-Service IntuneManagementExtension

Status should read Running. If the service is missing, the device hasn’t been assigned anything that needs the IME yet, or it isn’t Microsoft Entra joined.

PowerShell Get-Service showing the Intune Management Extension running, a prerequisite for Intune remediations
The IME running on my lab device. No IME, no remediations.

Step 4: Create a device group

Create a Microsoft Entra security group with assigned membership and add one or two test devices. Device groups suit Intune remediations that run as SYSTEM, which most should. Don’t mix user and device groups across include and exclude assignments.

Step 5: Write the detection and remediation scripts

The lab scenario is simple: if C:\Temp grows beyond 500MB, empty it. It’s a classic dumping ground for installers, exports and the odd ISO someone swore they’d delete.

The detection script measures the folder, writes the size to the output and exits 1 if it’s over the threshold. A missing folder counts as healthy. Save it as Detect-TempOver500MB.ps1:

$Path = 'C:\Temp'
$ThresholdBytes = 500MB

try {
    if (-not (Test-Path $Path)) {
        Write-Output "C:\Temp does not exist"
        exit 0
    }

    $Size = (Get-ChildItem $Path -Recurse -Force -ErrorAction Stop |
        Measure-Object Length -Sum).Sum

    if ($null -eq $Size) { $Size = 0 }

    Write-Output ("C:\Temp size: {0:N2} MB" -f ($Size / 1MB))

    if ($Size -gt $ThresholdBytes) {
        Write-Output "Issue detected: C:\Temp exceeds 500MB"
        exit 1
    }

    exit 0
}
catch {
    Write-Output "Detection error: $($_.Exception.Message)"
    exit 1
}

The remediation script deletes everything inside C:\Temp (the folder itself stays) and exits 0 when it’s done. Save it as Remediate-ClearTemp.ps1:

$Path = 'C:\Temp'

try {
    if (-not (Test-Path $Path)) {
        Write-Output "C:\Temp does not exist"
        exit 0
    }

    Write-Output "Clearing C:\Temp"
    Get-ChildItem $Path -Recurse -Force -ErrorAction Stop |
        Remove-Item -Recurse -Force -ErrorAction Stop

    Write-Output "C:\Temp cleared successfully"
    exit 0
}
catch {
    Write-Output "Remediation error: $($_.Exception.Message)"
    exit 1
}

Gotcha: the detection script’s catch block exits 1, so a detection error also triggers the clean-up. That’s fine here because the remediation copes with a missing folder, but think twice before copying the pattern into a script that deletes anything more precious than temp files.

Tip: save scripts as UTF-8 (without a BOM if you enforce signature checks), keep output under 2,048 characters, and never put restart commands, passwords or personal data in a script. Upload the .ps1 files rather than pasting into the browser so the encoding survives.

Step 6: Create the script package in Intune

  1. In the Microsoft Intune admin centre, go to Devices > Manage devices > Scripts and remediations.
  2. On the Remediations tab, select Create.
  3. On Basics, enter a name such as Clear C:\Temp over 500MB and a description. Publisher defaults to your name.
  4. On Settings, upload Detect-TempOver500MB.ps1 as the detection script file and Remediate-ClearTemp.ps1 as the remediation script file.
  5. Set the three options using the table below, then select Next.
  6. Add scope tags if you use them, then select Next.
SettingMy labWhy
Run this script using the logged-on credentialsNoRuns as SYSTEM, so it can clear the folder whoever is signed in, or with nobody signed in at all
Enforce script signature checkNoUnsigned scripts then run with the Bypass execution policy. Choose Yes only if you sign scripts and the certificate is in Trusted Publishers
Run script in 64-bit PowerShellYesAvoids 32-bit redirection surprises with registry and System32 paths. The default of No would also work for this script

Step 7: Assign and schedule the package

On Assignments, include your test device group, then edit the schedule next to it. There are three options:

ScheduleWhat it doesGood for
OnceRuns one time at a date and time you chooseOne-off checks and clean-ups
HourlyRuns every n hours, where n is less than 24Lab testing, or issues that genuinely come back quickly
DailyRuns at a set time each day, or every few daysMost production remediations

Times follow the device’s local clock unless you tick Use UTC. If a device misses a run because it was switched off, it catches up as soon as it’s back online.

I picked Hourly for the video so I didn’t have to fill the gap with small talk. For real devices, daily or even weekly is kinder to batteries, and nobody needs C:\Temp measured 24 times a day. Select Review + create, then Create.

How to run Intune remediations on demand

Waiting for a schedule is fine until it’s the head teacher’s laptop with the problem. The Run remediation device action fires a script package at a single Windows device straight away.

  1. In the Intune admin centre, go to Devices > By platform > Windows and open the device.
  2. On the Overview page, select the … menu and choose Run remediation. In my tenant it was labelled Run remediation (preview).
  3. Pick the script package. View details shows the scripts and settings before you commit.
  4. Select Run remediation.

The package has to exist in Intune but doesn’t need to be assigned to that device. The device must be online and able to reach Intune and the Windows Push Notification Service, and send one Run remediation at a time, because several in quick succession can overwrite each other.

To hurry a scheduled run instead, sync the device from Settings > Accounts > Access work or school > your work account > Info > Sync. That triggers an IME check-in as well as the usual MDM one.

How to prove Intune remediations worked

On the device

Check the folder size from PowerShell:

(Get-ChildItem C:\Temp -Recurse | Measure-Object Length -Sum).Sum / 1MB

After the remediation runs, the answer should be zero or close to it, and my oversized test file, bigfile.bin, should be gone.

In the Intune admin centre

Go back to Devices > Manage devices > Scripts and remediations. The list shows every package with counts for Without issues, With issues, Issue fixed and Recurred.

Intune remediations list in Scripts and remediations showing the Clear C:\Temp over 500MB package active with one issue fixed
My package sat next to the two built-in ones. One issue found, one issue fixed.

Open the package to see the Overview, which splits detection status (Without issues, With issues, Failed, Not applicable) from remediation status (Issue fixed, Recurred, Failed). Device status lists each device with its script output, and Export saves the lot to CSV.

Intune remediations overview for Clear C:\Temp over 500MB showing one device with issues and one issue fixed
One device with issues, one issue fixed, zero failures. I’ll take that.

For a single device, open it under Devices > By platform > Windows and select Remediations in the Monitor section.

Good to know: reporting isn’t instant. Recurring packages report when something changes and send a full report every seven days regardless, and the IME fetches policy after a restart, at sign-in and every eight hours. Make a cup of tea before deciding it hasn’t worked.

Intune remediations logs and troubleshooting

When the Intune remediations report says nothing useful, the device usually says more. The IME keeps its logs here, and CMTrace reads them far better than Notepad:

C:\ProgramData\Microsoft\IntuneManagementExtension\Logs
LogWhat to look for
HealthScripts.logScheduled remediations: when each package ran and how it finished
AgentExecutor.logPowerShell script execution details
IntuneManagementExtension.logCheck-ins, policy downloads and reporting
ClientHealth.logThe health of the IME itself
SymptomLikely cause
Package never runsDevice isn’t in the assigned group, the IME is missing, or the device isn’t Entra joined or hybrid joined
Create is greyed outWindows license verification isn’t turned on
Detection finds issues but nothing gets fixedDetection exits with something other than 1, or the package has no remediation script
Status stuck on pendingDevice offline, or waiting for the next IME check-in
Works in your console, fails in IntuneThe script depends on a user profile, mapped drive or 32-bit versus 64-bit path. Test as SYSTEM with psexec -i -s
Output missing or cut shortOutput over 2,048 characters, or the script swallows its own errors

More Intune remediations examples

The C:\Temp clean-up is a gentle start. The best candidates for Intune remediations share three traits: the problem keeps coming back, the fix is predictable and nobody should need to restart.

ProblemDetection checksRemediation doesRun as
Stopped serviceA service set to Automatic isn’t runningStarts it (script below)SYSTEM
Registry driftA value no longer matches your standardSets it back with Set-ItemPropertySYSTEM for HKLM, logged-on user for HKCU
Stale Group PolicyLast refresh is more than seven days oldRuns gpupdate (built-in package)Logged-on user
Office Click-to-Run stoppedThe Click-to-Run service isn’t runningRestarts it (built-in package)Just assign the built-in package
Expired user certificatesExpired certificates from your CA in the user storeDeletes them (Microsoft sample)Logged-on user
Low disk spaceFree space below a thresholdNothing: a detection-only package that reports itSYSTEM

That last row is worth remembering. A package can contain only a detection script, which turns Intune remediations into a cheap reporting tool for anything you can measure in PowerShell.

Example: restart the Windows Search service

Here’s a second package you can copy. It checks the Windows Search service (WSearch) and only acts if the service is installed and set to start automatically, so it won’t fight a device where search was disabled on purpose. Save the detection script as Detect-WindowsSearchStopped.ps1:

# Detect-WindowsSearchStopped.ps1
$ServiceName = 'WSearch'

try {
    $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue

    if ($null -eq $Service) {
        Write-Output "$ServiceName is not installed, nothing to do"
        exit 0
    }

    if ($Service.StartType -notlike 'Automatic*') {
        Write-Output "$ServiceName start type is $($Service.StartType), leaving it alone"
        exit 0
    }

    if ($Service.Status -ne 'Running') {
        Write-Output "Issue detected: $ServiceName is $($Service.Status)"
        exit 1
    }

    Write-Output "$ServiceName is running"
    exit 0
}
catch {
    Write-Output "Detection error: $($_.Exception.Message)"
    exit 1
}

And the remediation script as Remediate-StartWindowsSearch.ps1:

# Remediate-StartWindowsSearch.ps1
$ServiceName = 'WSearch'

try {
    Start-Service -Name $ServiceName -ErrorAction Stop
    (Get-Service -Name $ServiceName).WaitForStatus('Running', [TimeSpan]::FromSeconds(30))
    Write-Output "$ServiceName started"
    exit 0
}
catch {
    Write-Output "Remediation error: $($_.Exception.Message)"
    exit 1
}

Run both as SYSTEM. The remediation waits up to 30 seconds for the service and exits 1 if it doesn’t start, so a broken service shows as Failed rather than a cheerful but false Issue fixed. I checked the detection logic against missing, disabled, manual, stopped and running states, and you can swap WSearch for any service name.

Intune remediations gotchas

Locked files. The C:\Temp remediation uses -ErrorAction Stop, so a single file held open by an app stops the clean-up and the run reports Failed. If partial clean-ups are acceptable, switch Remove-Item to -ErrorAction SilentlyContinue and let the next detection judge the result.

Exit codes. Only exit 1 triggers a fix. A detection script that writes output but never exits 1 reports a perfectly healthy estate forever, which is lovely right up until it isn’t.

Software deployment. Intune remediations aren’t an installer. For apps, use Win32 app deployment in Intune instead.

Should you use Intune remediations?

If you have the licences, yes. Intune remediations turn the tickets you fix every week into scripts that fix themselves, and the reports show how often each problem actually happens, which is handy ammunition for the next budget meeting.

Start with one boring, low-risk package like the C:\Temp clean-up. Run it hourly on a test group, read HealthScripts.log, then move it to daily for everyone. For broader disk housekeeping, Storage Sense in Intune may do the job with no scripting, and Endpoint analytics helps you spot which problems deserve a package.

Just don’t let them become a home for every script you’ve ever written. Otherwise you’ve rebuilt C:\Temp, only this time inside Intune, and Windows 98 had better housekeeping than that.

Intune remediations FAQs

Do Intune remediations run as SYSTEM or as the user?

With Run this script using the logged-on credentials set to No, they run as SYSTEM, which suits most device fixes and works with nobody signed in. Set it to Yes for scripts that need the user’s profile, such as HKCU or the user certificate store.

What licence do I need for Intune remediations?

Each user needs Windows Enterprise E3 or E5 (included in Microsoft 365 F3, E3 and E5), Windows Education A3 or A5 (included in Microsoft 365 A3 and A5), or Windows VDA per user. Microsoft 365 Business Premium on its own generally doesn’t qualify.

How often do Intune remediations run?

As often as you schedule them: once, every few hours (under 24) or daily at a set time. Separately, the IME checks for new policy every eight hours, after a restart and when a user signs in.

What exit code should a detection script use?

Exit 1 when the problem is found, which triggers the remediation script, and exit 0 when the device is healthy. Any other exit code means the remediation won’t run.

Can I run an Intune remediation on demand?

Yes. Open the Windows device in the Intune admin centre and use the Run remediation device action. You need the Remote tasks/Run Remediation permission, and the device must be online.

What is the difference between Intune remediations and platform scripts?

Platform scripts run once when assigned. Intune remediations run on a schedule, check state with a detection script first and report detection and remediation results for every device.

Further reading

Found this useful? Buy me a coffee, and if you handle subject access requests, have a look at Redact Ninja for redacting PDFs without sending files to a server.

Tags:

4 responses to “Intune Remediations: Let PowerShell Fix It Before Dave From Accounts Rings”

  1. […] Intune Remediations Detect and Fix Issues Automatically says: 16 February 2026 at 12:45 […]

  2. […] cover how to build and deploy those in my Intune Remediations guide. Check the licensing section first, as Remediations has requirements that a Settings Catalog […]

  3. […] VDA per user. If you are on Business Premium, the Intune install status report is your friend. My Intune Remediations guide covers the full […]

Leave a Reply

Your email address will not be published. Required fields are marked *