M365 Admin Handbook — Chapter 8: Endpoint Security with Intune (Win32 App Deployment, Defender for Endpoint & Remediation Scripts)

📚 Mastering Microsoft 365 & Endpoint Administration Chapter 8 of 14
View Full Book TOC →
📘 Chapter 8 Executive Brief — Endpoint Security with Intune
  • Modern App Packaging: Standardize on Win32 apps (.intunewin) or the Intune Enterprise Application Management catalog for granular detection rules, supersedence, and dependencies—never rely on legacy MSI LOB mixing during Autopilot.
  • Defender for Endpoint Integration: Connect Intune directly to Microsoft Defender for Endpoint so real-time EDR device risk scores dynamically gate Conditional Access access to Microsoft 365.
  • Self-Healing Endpoints: Replace one-off startup scripts with Intune Remediations (Detection + Remediation PowerShell pairs) that automatically fix registry drift, stale services, and local admin violations on schedule.

In Chapter 7, we configured Windows Autopilot, automatic MDM enrollment, and compliance policies. Now we harden and operationalize those endpoints at scale using Win32 App Deployment, Microsoft Defender for Endpoint (MDE) integration, and Intune Remediations.


1. Intune Endpoint Security & App Delivery Architecture

Intune Endpoint Security, Win32 App Delivery & Self-Healing Loop 1. WIN32 & ENTERPRISE CATALOG • IntuneWinAppUtil.exe (.intunewin) • Enterprise App Management Catalog • Strict Detection + Supersedence Intune Management Extension (IME) 2. DEFENDER FOR ENDPOINT • Auto-Onboarding via Intune Profile • ASR Rules + Tamper Protection • MDE Risk Score → Compliance Gate Blocks High-Risk Devices in Entra 3. PROACTIVE REMEDIATIONS • Detection Script (Exit 0 / Exit 1) • Remediation Script on Exit 1 • Daily / Hourly Fleet Drift Healing Zero Helpdesk Tickets Best Practice: Never mix Line-of-Business (LOB) MSI apps and Win32 apps during the same Autopilot Enrollment Status Page (ESP) phase.

2. Packaging & Deploying Win32 Apps (.intunewin) Cleanly

Every Win32 app deployed via the Intune Management Extension (IME) requires the Microsoft Win32 Content Prep Tool (IntuneWinAppUtil.exe):

POWERSHELL
# Package a silent installer (e.g., 7-Zip or custom agent MSI/EXE) into .intunewin
.\IntuneWinAppUtil.exe `
    -c "C:\IntunePackages\Source\7Zip" `
    -s "7z2408-x64.msi" `
    -o "C:\IntunePackages\Output" `
    -q

Production Win32 Deployment Rules:

  • Install behavior: Always select System for machine-wide tools and 64-bit context in Detection Rules so registry checks don't silently redirect to WOW6432Node.
  • Return codes: Keep standard 0 (Success), 1707 (Success), 3010 (Soft Reboot), and 1641 (Hard Reboot).
  • Supersedence: Use Intune App Supersedence to upgrade older Win32 versions cleanly instead of pushing overlapping uninstall scripts.

3. Integrating Microsoft Defender for Endpoint (MDE) with Intune

In Microsoft Intune Admin Center → Endpoint security → Microsoft Defender for Endpoint:

  1. Toggle Connect Microsoft Defender for Endpoint to Microsoft Intune to On (and enable Allow Microsoft Defender for Endpoint to enforce Endpoint Security Configurations for Security Settings Management).
  2. Create an Endpoint Detection and Response (EDR) Onboarding Policy targeting all corporate Windows 10/11 devices.
  3. Enable Attack Surface Reduction (ASR) rules (start in Audit mode for 14 days, then switch to Block—especially Block credential stealing from LSASS and Block Office applications from creating executable content).
  4. Update your Device Compliance Policy (Chapter 7) to require Microsoft Defender for Endpoint Machine Risk Score ≤ Low.

4. Building Self-Healing Intune Remediations (Detection + Remediation)

Intune Remediations (Devices → Scripts and remediations) run a lightweight PowerShell Detection script on a schedule. If it exits 0, nothing happens; if it exits 1, Intune automatically triggers the Remediation script.

Example: Detect & Remediate Unauthorized Local Administrators

Detection Script (Detect-RogueLocalAdmins.ps1):

POWERSHELL
$allowedAdmins = @("Administrator", "BuiltInAdmin", "LAPSAdmin")
$members = Get-LocalGroupMember -Group "Administrators" -ErrorAction SilentlyContinue |
    Where-Object { $_.ObjectClass -eq "User" -and $_.PrincipalSource -eq "Local" }

$rogue = $members | Where-Object {
    $shortName = ($_.Name -split "\\")[-1]
    $shortName -notin $allowedAdmins
}

if ($rogue) {
    Write-Output "Rogue local admin(s) detected: $($rogue.Name -join ', ')"
    exit 1
} else {
    Write-Output "Local Administrators group is compliant."
    exit 0
}

Remediation Script (Remediate-RogueLocalAdmins.ps1):

POWERSHELL
$allowedAdmins = @("Administrator", "BuiltInAdmin", "LAPSAdmin")
$members = Get-LocalGroupMember -Group "Administrators" -ErrorAction SilentlyContinue |
    Where-Object { $_.ObjectClass -eq "User" -and $_.PrincipalSource -eq "Local" }

foreach ($m in $members) {
    $shortName = ($m.Name -split "\\")[-1]
    if ($shortName -notin $allowedAdmins) {
        Remove-LocalGroupMember -Group "Administrators" -Member $m.Name -ErrorAction Stop
        Write-Output "Removed unauthorized local admin: $($m.Name)"
    }
}

Chapter 8 Verification Checklist

  • [ ] All custom enterprise apps are packaged as Win32 (.intunewin) or deployed via Enterprise Application Management.
  • [ ] Microsoft Defender for Endpoint is connected to Intune, and compliance policies enforce Risk Score ≤ Low.
  • [ ] Attack Surface Reduction (ASR) rules and Tamper Protection are deployed via Endpoint Security profiles.
  • [ ] At least one Intune Remediation script package is actively monitoring configuration drift across your fleet.

References & Official Microsoft Documentation

💬 Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.