How it works
Microsoft Intune is the device management service of a Microsoft Entra tenant. It is a software deployment system by design: an administrator uploads something, assigns it to a group, and the Intune management extension on each Windows device runs it. An attacker who controls an identity with Intune rights uses that channel instead of bringing a tool of their own. It is the cloud counterpart of Group Policy abuse and SCCM application deployment abuse.
The objects that carry code or configuration to devices:
- Platform scripts. A PowerShell script uploaded under Devices > Scripts and remediations. With "Run this script using the logged on credentials" set to No it runs in the system context. No user needs to be signed in.
- Remediations. Script packages with a detection and a remediation script that run on a schedule, so the code runs again and again.
- Apps. A Win32 app with the install behavior System runs its install command as SYSTEM.
- Configuration profiles and compliance policies. They change the device's settings: local group membership, trusted certificates, security features, and what counts as compliant. A weakened compliance policy also makes non-compliant devices pass Conditional Access.
Two properties make this more than a single action. The assignment stays in force after the administrator who created it has left or been removed, and it applies to every device that later joins the assigned group. And Intune records the administrative change, not the execution: the audit event says a script was created or assigned, while each device decides on its own when it checks in and runs it.
The link to Entra ID is direct. The Intune Administrator role is an Entra directory role, Intune's own roles are assigned to Entra groups, and applications reach Intune through Microsoft Graph permissions such as DeviceManagementScripts.ReadWrite.All, DeviceManagementConfiguration.ReadWrite.All and DeviceManagementApps.ReadWrite.All.
Prerequisites
- Control of an identity that can create or assign scripts, remediations, apps or profiles: the Intune Administrator or Global Administrator role, an Intune role such as Policy and Profile Manager or Application Manager, or an application with one of the device management Graph permissions above.
- Target devices that are enrolled in Intune and inside the scope of that identity's role assignment.
- No Multi Admin Approval access policy for the object type, or control of a second approver.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Choose the target devices
The attacker wants devices where privileged people sign in. Groups that hold administrator workstations, or the built-in "all devices" target, are the usual choices.
Connect-MgGraph -Scopes 'DeviceManagementManagedDevices.Read.All', 'Group.Read.All'
# Enrolled Windows devices with their primary user
Get-MgDeviceManagementManagedDevice -All -Filter "operatingSystem eq 'Windows'" |
Select-Object DeviceName, UserPrincipalName, AzureAdDeviceId, LastSyncDateTime
2. Create a platform script
The script body is sent Base64-encoded. runAsAccount set to system gives the system context:
Connect-MgGraph -Scopes 'DeviceManagementScripts.ReadWrite.All'
$content = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((Get-Content .\inventory.ps1 -Raw)))
$params = @{
displayName = 'Device inventory'
description = 'Collects hardware inventory'
scriptContent = $content
runAsAccount = 'system'
fileName = 'inventory.ps1'
roleScopeTagIds = @('0')
}
$script = New-MgBetaDeviceManagementScript -BodyParameter $params
The underlying call is POST https://graph.microsoft.com/beta/deviceManagement/deviceManagementScripts. A token for an application with the script permission works the same way as a signed-in administrator.
3. Assign it to a group
Nothing runs until the script is assigned. The assign action takes a list of targets:
$assign = @{
deviceManagementScriptAssignments = @(
@{
target = @{
'@odata.type' = '#microsoft.graph.groupAssignmentTarget'
groupId = '00000000-0000-0000-0000-000000000000'
}
}
)
}
Set-MgBetaDeviceManagementScript -DeviceManagementScriptId $script.Id -BodyParameter $assign
4. Wait for check-in and collect
Each device in the group downloads and runs the script at its next check-in with the Intune management extension. The script's device status report in the admin center shows which devices have run it and with what result. What the script does is up to the attacker: add a local administrator, start a remote access tool, or read the credentials and tokens of the signed-in user, for example the Primary Refresh Token.
5. Variants
- Remediation: the same idea with a script package and a schedule, which re-runs the code and restores the foothold if it is removed from a device.
- Win32 app: an app package whose install command runs as SYSTEM, assigned as required.
- Configuration profile: no code at all. A profile adds an account to the local Administrators group, installs a trusted root certificate or turns off a protection, and stays applied.
Impact
Code execution as SYSTEM on every targeted device. That is enough to read the credentials and tokens of the people who use the device, turn off endpoint protection and stay on the machine. One assignment can reach the whole fleet within one check-in cycle, which makes this a lateral movement step from the cloud control plane to endpoints, and through administrators' workstations back to higher cloud privilege.
Configuration changes have a longer tail. A profile keeps applying after the attacker loses access, new devices in the assigned group receive it automatically, and some settings stay on a device after the profile is unassigned.
OPSEC and artifacts
- Assign narrowly. A script assigned to a small group of administrator workstations runs on a handful of machines and is easy to miss among other objects. An assignment to all devices is fast but stands out. Either way the Intune audit log records the create and the assign operation with the actor and the object name.
- Name it like the rest. Scripts called inventory, cleanup or onboarding look like the tenant's own. The audit event names the object but does not contain the script body, so the content is only visible to someone who opens the script in the admin center.
- Edit an existing script. Changing the content of a script that is already assigned avoids a new object and a new assignment. It is logged as an update of that script.
- Use an application token. Calls made by an application appear with the application as the actor, which reviewers often read as automation.
- Remove it afterwards. Deleting the script hides it from the admin center. The audit log keeps the create, assign and delete operations, and devices that already ran it keep whatever it did.
- On the device. The Intune management extension writes its activity to its log folder under
C:\ProgramData\Microsoft\IntuneManagementExtension\Logs, and the script runs as a PowerShell process started by the extension. Endpoint telemetry sees that process and its children even when the cloud audit trail was not collected. - Two identifiers. The Intune managed device ID and the Entra device ID are different values. Joining audit events to devices by display name fails after a re-enrollment.
Detection
The Intune audit log reaches a SIEM only after a diagnostic setting sends the AuditLogs category to a Log Analytics workspace or event hub. Without it, the log is only in the Intune admin center and Graph.
- New or changed scripts, remediations and apps. The Intune script or app deployment rules match operations on platform scripts and remediation packages, and app assignments to all devices or all users.
- Role and scope changes. Intune role assignment changed covers an attacker giving themselves script or app permissions first.
- Approval controls removed. Multi Admin Approval policy changed covers the step that comes before an unapproved deployment.
- Compliance weakened. Intune compliance policy changed.
- Applications gaining Intune permissions. Intune Graph permission granted to an application.
// Script and remediation operations in the Intune audit log
IntuneAuditLogs
| where OperationName has_any ("DeviceManagementScript", "DeviceHealthScript")
| project TimeGenerated, OperationName, ResultType, Identity, Properties
| order by TimeGenerated desc
// Inventory of operation names, to learn what your tenant writes
IntuneAuditLogs
| summarize Events = count(), First = min(TimeGenerated), Last = max(TimeGenerated)
by OperationName, ResultType
| order by Last desc
Microsoft does not publish the full list of operation names, so start with the inventory query and confirm the names your tenant produces. An event count in this table does not tell you which devices ran a script; that comes from the script's device status and from endpoint telemetry.
Mitigation
- Turn on Multi Admin Approval with access policies for Scripts and Apps, so a second administrator must approve every new or changed deployment. Calls through Graph are held for approval too.
- Use Intune roles with narrow scope instead of the Intune Administrator directory role. Give script and app permissions to few people, with scope groups and scope tags that match their job, and make the directory role eligible through PIM as described in the PIM guide.
- Keep privileged access workstations out of general scope. Devices used by tenant administrators should be manageable only by a small, separate group of Intune administrators.
- Review applications with device management Graph permissions and remove the ones that do not need write access.
- Enforce script signature check where a signing process exists, and control who can sign.
- Export the Intune audit log to your SIEM and alert on new scripts, remediations and broad assignments.
- When responding, save a copy of the script or package, remove the assignment first and then the object, remove the actor's Intune role or the application's permission, and treat every device that ran it as compromised: reset the credentials and revoke the sessions of the people who used those devices.
Detection rules for this attack
FAQ
Why is Intune Administrator a Tier 0 level role?
Because it can run code as SYSTEM on every enrolled Windows device, without touching the devices directly. If administrators' workstations are enrolled and in scope, the holder can read the credentials and tokens of those administrators. The path from Intune Administrator to Global Administrator is one script assignment and one privileged sign-in on a managed device.
Does the user have to be signed in for a pushed script to run?
No. A platform script that is set to run in the system context does not need a signed-in user. The device only has to check in with Intune. Devices that are offline receive the script when they come back, which is why an assignment keeps producing new executions long after it was created.
Does removing the attacker's admin account undo the change?
No. The script, app or profile and its assignment stay in Intune and keep applying to devices until someone removes them. Some settings also stay on a device after the profile is unassigned. Clean-up has to cover the Intune objects, the assignments and the state of each device that processed them.
How do you detect malicious use of Intune?
Send the Intune audit log to a Log Analytics workspace or SIEM with a diagnostic setting and alert on created, changed and assigned scripts, remediations and apps, especially assignments to all devices or all users. The audit event names the object and the actor but does not contain the script body, so save a copy of the script when you investigate.
References
- Software Deployment Tools, T1072 (MITRE ATT&CK)
- Use PowerShell scripts on Windows devices in Intune (Microsoft Learn)
- Use audit logs to track and monitor events in Microsoft Intune (Microsoft Learn)
- Use Microsoft Graph with Multi Admin Approval (Microsoft Learn)
- deviceManagementScript assign action (Microsoft Graph beta)
- IntuneAuditLogs table (Azure Monitor reference)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.