Intune Automation for Device Management with PowerShell and Self-Service

Microsoft Intune automates enrollment, policies and compliance on its own, yet the ticket queue for device actions never empties. Sync this laptop, retire that one, rotate a BitLocker key. Each request waits for an admin, because the helpdesk has no Intune role and nobody wants to hand one out.

This article explains what Intune automation looks like with Microsoft Graph PowerShell, which permissions the actions need, and how the helpdesk requests device actions without becoming an administrator.

What Intune automation means in practice, and where the admin center stops

Intune automation is the practice of running Microsoft Intune device management tasks from scripts and workflows instead of from the admin center. Every button in the Intune admin center, from Sync to Retire to Wipe, is a call to the Microsoft Graph application programming interface (API) underneath. Whatever an admin can click, a script can do, and whatever a script can do, a request form in a tool such as the au2mator Self-Service Portal can trigger for someone who holds no Intune role at all.

Microsoft documents the full list of remote device actions on Microsoft Learn, from Autopilot Reset and BitLocker key rotation to Retire and Wipe. In the admin center each is a few clicks per device, in a script one line with a device ID. The difference is not the action. It is who starts it and how much privilege that person needs.

The four layers of Intune automation from the admin center to a self-service requestWhere Intune automation happens1. Intune admin centerSync, Retire, Wipe, Restart andthe other remote actions,a few clicks per device, by an admin2. Microsoft Graph APIEvery button is an API call,for example POST …/managedDevices/{id}/wipewith the PrivilegedOperations permission3. Your scripts on your engineGraph PowerShell on PowerShell,Azure Automation or Orchestrator,run under a service identity4. Request layer (au2mator)Who may start which action,with which form, approval and log,without holding an Intune role
Every Intune action exists on four layers. The admin center and Graph belong to Microsoft, the scripts and the request layer are yours.

Intune already automates a lot on its own through dynamic groups, compliance policies, remediation scripts and Autopilot. What stays manual is the long tail of individual requests that a person has to decide on. Retire this device because the employee left. Push a sync because the app is missing. Rotate the BitLocker key after a support session. Those requests land in the ticket queue, and that queue is what this article automates, with your scripts and with au2mator.


Why Intune device management still fills the ticket queue

Microsoft’s answer to the queue is role-based access control (RBAC), the permission model that assigns Intune roles to groups of admins. The built-in Help Desk Operator role performs remote tasks on users and devices, custom roles can narrow that down to single remote tasks such as Sync, and scope tags and scope groups limit which devices an assignment can touch, as the RBAC documentation on Microsoft Learn explains. For the riskiest actions, Multi Admin Approval requires a second admin to approve a wipe, retire or delete before it runs.

In practice three gaps remain. Every agent with a role still works in the admin center and becomes one more Intune admin to train, review and, by default, license. The approval covers three actions and runs between admins only, so the people who actually know whether a device should go, the team lead or the asset owner, are not part of it. And the request context lives elsewhere, because the audit log records who clicked, not who asked and why. So many IT teams keep the roles in the admin team and let the helpdesk forward tickets, which brings the queue right back. A self-service layer like au2mator removes the forwarding step without handing out a single Intune role.


Four ways to automate Intune

Automation here means that a device action runs from a defined input, with the same checks and the same log entry every time. There are four ways to get there, and they are not exclusive.

ApproachHow it worksPrerequisitesTypical fit
Intune built-in featuresDynamic groups, compliance policies, filters, remediation scripts and Autopilot handle the rule-based partIntune licensing, well-designed groups and policiesEvery tenant, as the foundation for everything else
Your own Graph PowerShell scriptsScripts call the Intune endpoints of Microsoft Graph to sync, retire, wipe, rename or regroup devices, on PowerShell, Azure Automation or System Center OrchestratorGraph PowerShell skills, an app registration or managed identity with the Intune permissions, a place to run the scriptsTeams that already automate Entra ID and Active Directory with scripts
Your scripts plus the au2mator Self-Service PortalThe same scripts with a web form in front, so the helpdesk or a team lead requests, an owner approves if needed, and a service account runs the script on the three engines au2mator connects toYour existing scripts, au2mator, a service account with the Intune permissionsOrganizations that want the helpdesk to act on devices without holding an Intune role
RMM and endpoint suitesRemote monitoring and management platforms add their own agent, console and workflow engine on top of IntuneA platform project, agent rollout, licensing per deviceManaged service providers and very large fleets with many non-Microsoft systems

Most organizations in the Microsoft stack end up with the first two rows. The third row decides whether those scripts remove tickets or only shorten them, because a script that only an admin can start still needs the admin.


The PowerShell behind Intune automation

The current toolset is the Microsoft Graph PowerShell software development kit (SDK), which replaced the older Intune-specific module. You connect with Connect-MgGraph, read devices with Get-MgDeviceManagementManagedDevice, and act on them with Sync-MgDeviceManagementManagedDevice, Invoke-MgRetireDeviceManagementManagedDevice or Clear-MgDeviceManagementManagedDevice, which is the wipe. The retire cmdlet reference and the wipe API documentation on Microsoft Learn list the options, such as keeping enrollment data or user data on a wipe.

Permissions are where most scripts go wrong. Reading devices needs DeviceManagementManagedDevices.Read.All. Sync, retire, wipe, restart and the other remote actions need DeviceManagementManagedDevices.PrivilegedOperations.All, which Microsoft classifies as a high-impact permission that requires admin consent. For unattended runs on Azure Automation the clean pattern is a managed identity that holds exactly these application permissions, plus User.Read.All for the user check below, so no client secret sits in a variable. A production script validates the input, checks a guard, executes the action and writes a result. A shortened retire script for a leaver’s personal device looks like this.

param([string]$DeviceName, [string]$Reason)
Connect-MgGraph -Identity -NoWelcome

$device = Get-MgDeviceManagementManagedDevice -Filter "deviceName eq '$DeviceName'"
if (@($device).Count -ne 1) { throw "Expected exactly one device named $DeviceName" }

$user = Get-MgUser -UserId $device.UserId -Property AccountEnabled
if ($user.AccountEnabled) { throw "Primary user is still active, retire refused" }

Invoke-MgRetireDeviceManagementManagedDevice -ManagedDeviceId $device.Id
Write-Output "Retired $($device.DeviceName), reason $Reason"

The guard turns the script into a policy, because it refuses to retire a device whose user is still active. The script runs the same way whether a schedule, a CSV import or a person triggers it. The ticket queue only disappears when the person who has the request can also start it.


How au2mator lets the helpdesk run your Intune scripts without an Intune role

Here is the gap in most Intune automation guides. The retire script needs two values that only the helpdesk agent has in front of them, the device and the reason. The agent has no Intune role, so the values travel by ticket to an admin who pastes them into a parameter block. The script saved the clicking, not the waiting.

The au2mator Self-Service Portal closes this gap, and the design decision that matters is that it brings no engine and no Intune connector of its own, only a set of ready-made PowerShell scripts you can start from. A service in au2mator is your PowerShell script, your Azure Automation runbook or your System Center Orchestrator runbook, registered once with its parameters. Nothing in the script is rewritten. The helpdesk agent opens the portal, picks “Retire device”, fills in a form whose fields are the script parameters, and submits. If the service requires it, the asset owner approves. A service account that holds the Graph permissions executes the script, and the agent holds no Intune role at all.

How an Intune device request flows from the helpdesk to the device without admin rightsHow au2mator gets from request to device action without an Intune role1. Helpdesk agentOpens the portal, picksRetire device, fills indevice, reason, ticket number2. au2mator formFields are the script parameters,device lookup, reason dropdown,wipe only where intended3. ApprovalOptional per service,none for a sync, one owner fora retire, a group for a wipe4. au2mator runs it on your engineService account with the Graph permissionexecutes your unchanged script onPowerShell, Azure Automation orSystem Center OrchestratorGet device, guard check, retire, result5. Result and auditDevice is retired in IntuneRequester gets a confirmationAudit log with requester, approver,device, reason, result and timeAgent holds no Intune role
In the au2mator request flow the helpdesk agent fills in a form, an owner approves where needed, and a service account runs your unchanged script on your engine.

What an Intune device service looks like in au2mator

The service is your existing Graph PowerShell script, or one of the ready-made PowerShell scripts that ship with au2mator, published once with its parameters. The form turns each parameter into a field. The device is a lookup against your managed devices rather than free text, the reason is a dropdown with the values your audit expects, and a wipe option is only shown on the service that is meant to wipe. Permissions decide who sees what. First-level agents see “Sync device” and “Rotate BitLocker key”, second level sees “Retire device”, and nobody sees the admin center. Approval is optional per service, for example none for a sync, the asset owner for a retire, and the asset owner group for a wipe, where you decide whether one member or a defined share of the group has to approve. For execution, au2mator starts the script through the API of your engine, and the script itself signs in with the service account or managed identity that holds the Graph permissions, so the agent’s own identity never needs PrivilegedOperations.All. The audit trail stores requester, approver, parameters, result and timestamp for every request, and the result can be reported back to your ticketing tool. “Restart device”, “Collect diagnostics” and “Add device to pilot group” are more services on the same engine.


Device lifecycle automation from enrollment to retirement

Single actions are the visible half of Intune automation. The half that decides how clean your tenant stays is the device lifecycle, from enrollment to retirement. The transitions in between are where the manual work hides, and they follow the same joiner, mover and leaver pattern we described for user accounts in our article on user provisioning automation.

The device lifecycle from enrollment to retirement with the automation point in each phaseThe device lifecycle and where automation takes overEnroll and assignAutopilot group, primary user,department groups with apps and policiesTriggered when the user account existsMoveDepartment change moves the deviceinto the groups with the new appsRequested by the team leadMaintainSync, restart, BitLocker key rotation,diagnostics, as single servicesRequested by the helpdeskRetire or wipeRetire a leaver’s personal device,wipe corporate hardware for reuseStale devices reported after 90 days
Enrollment and policies are automated by Intune itself. The transitions in between are scripts, and with au2mator they become requests.

A new hire gets a device in the Autopilot group and a user assignment the moment the account exists. A department change moves the device into the groups that carry the new apps and policies. A leaver’s personal device, the classic bring your own device (BYOD) case, is retired on the day the account is disabled, while a returned corporate laptop gets a wipe or Autopilot Reset before the next user. With au2mator these are services on the same engine, requested by HR, the team lead or the helpdesk and logged every time.


FAQ: Intune automation

What is Intune automation?

Intune automation means running Microsoft Intune tasks from scripts, scheduled jobs or request workflows instead of clicking through the admin center. Because every admin center action is a Microsoft Graph API call, anything from syncing a device to retiring it can run from PowerShell, Azure Automation or a self-service request, with a log entry each time.

How do I automate Intune with PowerShell?

Install the Microsoft Graph PowerShell SDK, connect with Connect-MgGraph and the scopes your task needs, and use the device management cmdlets, for example Get-MgDeviceManagementManagedDevice to find a device and an action cmdlet such as Invoke-MgRetireDeviceManagementManagedDevice to act on it. For unattended runs, use an app registration or managed identity with application permissions instead of a user login.

Which Graph permissions do Intune device actions need?

Reading devices needs DeviceManagementManagedDevices.Read.All. Remote actions such as sync, retire, wipe, restart or remote lock need DeviceManagementManagedDevices.PrivilegedOperations.All, a high-impact permission that requires admin consent. Keep it on a dedicated service identity. In au2mator that identity runs the script, while the person who requests the action holds no Graph permission at all.

Can the helpdesk run Intune device actions without an Intune role?

Not with Intune alone. The Help Desk Operator role or a custom role with single remote tasks still makes the agent an Intune admin in the admin center. The alternative is a self-service portal such as au2mator, where the agent fills in a form, an approval runs if your policy requires it, and a service account executes your unchanged script on PowerShell, Azure Automation or System Center Orchestrator.

What is the difference between retire and wipe in Intune?

Retire removes the device from Intune management and strips company data, apps and policies, while personal data stays on the device. Wipe resets the device to factory settings, with options such as keeping enrollment data or user data. Retire is the typical action for a leaver’s personal device, while wipe or Autopilot Reset prepares corporate hardware for the next user or protects a lost one.

Should I run Intune scripts on Azure Automation or on a server?

Azure Automation is the natural home for cloud-only Intune scripts, with a managed identity for authentication and schedules for recurring jobs. A PowerShell host or System Center Orchestrator fits when the same workflow also touches on-premises Active Directory. au2mator works with all three, so the choice follows your environment.


Conclusion: Intune automation is a question of who may press the button

Microsoft Intune gives you the actions and the API, Graph PowerShell gives you the scripts, and Azure Automation gives you a place to run them. What none of them solves is the step where a request turns into an action, and that step is where tickets, overprivileged helpdesk roles and audit gaps come from. The fix is the pattern that works for every identity and device task. A script applies your rules, a service account runs it, and a form in front lets the people who have the request start it without becoming Intune administrators.

If you want to see how your current Intune scripts could become self-service requests for your helpdesk, with approval, least privilege and a full audit trail, book a 30-minute call with Michael Seidl, Microsoft MVP and founder of au2mator, and bring the device tickets that annoy you most.

Do more with au2mator!

Self-Service portal with three automation engines

Similar articles

Intune automation: a Retire device request form in the au2mator Self-Service Portal with Sync, Retire and BitLocker key services, no admin rights needed

Intune Automation for Device Management with PowerShell and Self-Service

Microsoft Intune automates enrollment, policies and compliance on its own, yet the ticket queue for device actions never empties. Sync this laptop, retire that one, ...

User provisioning automation: a new employee form with name, department, start date and manager, started from one request for joiner, mover and leaver

User Provisioning Automation for Onboarding, Changes and Offboarding

Every new starter means a ticket from HR, twelve clicks across four consoles and groups copied from a colleague. Department changes arrive as a mail, ...

au2mator – Self Service Portal 5.1.4 released

Discover the exciting new features in au2mator Version 5.1.4! We’ve introduced Scoped Admins for tailored control, enhanced Maintenance Mode for Services, and improved filtering in ...

8 Ways to Screw Your Azure Automation