Decommissioning Windows Devices in Intune: Retire, Wipe, Cleanup
Step-by-step guidance for retiring or wiping Windows devices in Intune, removing Autopilot identities, and clearing Entra ID and AD records safely.

In this lesson
Table of Contents
Table of contents
Before you begin
- Basic familiarity with the Intune admin centre and device enrollment concepts
- Comfortable running Microsoft Graph PowerShell SDK commands
- Understanding of Entra ID device objects and hybrid Azure AD join
Track this tutorial
Choose your current status and tick each safety check as you complete it. Sign in to sync progress between devices.
Current status
Tutorial stages
- Step 1: Inventory and confirm device identity
- Step 2: Confirm data preservation
- Step 3: Raise and approve the change
- Step 4: Execute the correct removal action
- Step 5: Remove the Windows Autopilot device identity
- Step 6: Clean up Entra ID and hybrid AD remnants
0 of 6 stages complete
Before you apply the change
Confirm these production-safety controls during the tutorial.
#Operational requirement
Hardware refreshes and leaver offboarding generate a recurring, unglamorous task: taking a Windows device out of active management without leaving orphaned objects behind. This is usually one of the first real production assignments handed to a new endpoint engineer — “decommission these fourteen laptops from the finance floor refresh” or “process this leaver’s device by Friday”. It looks trivial. It is not.
Get the sequencing wrong and you produce one of three production incidents. First: you issue a full Wipe against the wrong serial number and destroy a working device’s local data with no way to recover it, because Wipe is irreversible by design. Second: you Retire a device and remove it from Intune but forget to delete the Windows Autopilot device identity, so when that laptop is reimaged and handed to the next starter, Autopilot enrolment fails or silently reapplies the departed user’s old deployment profile. Third: you clean up Intune but leave the Entra ID device object and the hybrid on-prem AD computer object in place, which keeps a licence seat consumed and leaves a stale identity that a security audit will flag months later as an unaccounted-for endpoint.
This runbook walks a junior administrator through the correct decommission sequence: inventory and confirm, obtain change approval, execute the correct removal action (Retire versus Wipe), clean up the Autopilot identity, clean up Entra ID and any hybrid AD remnants, and produce verifiable evidence that the device is fully retired from every system of record. Follow it step by step; do not skip the confirmation steps because the ticket seems routine.
#Prerequisites and required permissions
- An Entra ID account assigned the Intune Administrator role, or a custom Intune RBAC role granting Managed Devices “Delete” and “Wipe” permissions.
- Entra ID Cloud Device Administrator role, or equivalent, to remove device objects.
- Microsoft Graph PowerShell SDK installed on your admin workstation:
Install-Module Microsoft.Graph -Scope CurrentUser- Graph delegated scopes:
DeviceManagementManagedDevices.PrivilegedOperations.All,DeviceManagementManagedDevices.ReadWrite.All,Device.ReadWrite.All, andDeviceManagementServiceConfig.ReadWrite.Allfor Autopilot identity deletion. - An approved change record in your service management tool — bulk device wipe actions should never proceed on a verbal request alone.
- Confirmation that user data preservation, such as OneDrive Known Folder Move, has already completed, or an explicit written sign-off that no data preservation is required, for any device going through Wipe rather than Retire.
- Read access to your asset register so serial numbers can be cross-checked before any destructive action is issued.
#Step 1: Inventory and confirm device identity
Before touching anything, pull the exact managed device record and confirm you have the right hardware. Serial numbers and device names get transposed in spreadsheets constantly — this is the single most common cause of the “wrong device wiped” incident, and it is entirely preventable with one extra query.
1Connect-MgGraph -Scopes "DeviceManagementManagedDevices.PrivilegedOperations.All","DeviceManagementManagedDevices.ReadWrite.All","Device.ReadWrite.All"
2
3Get-MgDeviceManagementManagedDevice -Filter "deviceName eq 'FIN-LT-0231'" | Select-Object Id, DeviceName, SerialNumber, UserPrincipalName, ManagedDeviceOwnerType, EnrolledDateTime, LastSyncDateTime, ComplianceStateExpected result: a single device record returned with a serial number matching your asset register. Evidence to capture: export this record into the change ticket before proceeding. Checkpoint: if ManagedDeviceOwnerType shows personal, stop. BYOD devices go through a Retire, never a full Wipe, and require a separate consent conversation with the user.
#Step 2: Confirm data preservation
For corporate-owned devices going to full Wipe, verify OneDrive sync health for the assigned user, or obtain explicit written confirmation from the requesting manager that no data preservation is needed. Record the confirmation reference number in the ticket. This step exists because Wipe with keepUserData set to false is destructive, and Microsoft does not offer a recovery path from the managed-device side once the command has processed.
#Step 3: Raise and approve the change
Log a standard change with the device list, the action per device (Retire or Wipe), and a rollback plan attached. For batches larger than five devices, route the request through your change advisory board or equivalent lightweight approval. This is not because the technical risk is high; it is because the blast radius of a scripting mistake against the wrong device group is large enough to justify a second pair of eyes on the filter logic before execution.
#Step 4: Execute the correct removal action
Retire and Wipe are not interchangeable. Use the decision table below before issuing either command.

| Scenario | Action | Effect |
|---|---|---|
| Leaver, corporate device returns for reissue | Wipe (keepUserData:false) | Full factory reset, removes MDM enrolment and all local data |
| BYOD, user leaving the programme | Retire | Removes corporate data and management profile only, personal data untouched |
| Device replaced under warranty, returned to vendor | Wipe | Ensures no residual corporate data leaves the estate |
| Device stolen or lost | Retire immediately, Wipe once or if recovered | Retire triggers a selective wipe fastest if the device ever calls home |
Issue the action via Graph:
1$deviceId = (Get-MgDeviceManagementManagedDevice -Filter "deviceName eq 'FIN-LT-0231'").Id
2
3# Wipe example
4Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/$deviceId/wipe" -Body (@{ keepEnrollmentData = $false; keepUserData = $false } | ConvertTo-Json)
5
6# Retire example
7Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/$deviceId/retire"Expected result: HTTP 204 No Content on success. Evidence to capture: the response status, timestamp and device ID, pasted into the change ticket. Checkpoint: the action only processes when the device next checks in. If it has been offline more than ninety days, note this in the ticket and set a follow-up reminder rather than assuming completion.
#Step 5: Remove the Windows Autopilot device identity
This step is skipped constantly, and it is the reason reissued hardware breaks on the next starter’s first day. If the Autopilot identity remains registered, the next enrolment attempt either fails outright or silently reapplies the previous deployment profile and Enrollment Status Page settings.
1$autopilotDevice = Get-MgDeviceManagementWindowAutopilotDeviceIdentity -Filter "contains(serialNumber,'PF3XK912')"
2Remove-MgDeviceManagementWindowAutopilotDeviceIdentity -WindowsAutopilotDeviceIdentityId $autopilotDevice.IdExpected result: the serial number no longer appears under Devices, Enrollment, Windows Autopilot Devices in the Intune admin centre. Evidence: a before-and-after screenshot of the Autopilot device list. Checkpoint: if the hardware was purchased through a reseller with Autopilot registration tied to the OEM, deletion here only removes the tenant assignment. The hardware hash itself may need re-registration on next enrolment, which is expected and not a fault.
#Step 6: Clean up Entra ID and hybrid AD remnants
Once the Intune object and Autopilot identity are gone, remove the corresponding Entra ID device object. If the estate is hybrid-joined, remove the on-prem AD computer object too, otherwise Entra Connect will resurrect a stale device record on the next sync cycle.
Get-MgDevice -Filter "displayName eq 'FIN-LT-0231'" | Remove-MgDeviceFor hybrid environments, run the equivalent cleanup on-prem:
Remove-ADComputer -Identity "FIN-LT-0231" -Confirm:$falseFinally, unassign the Microsoft 365 licence from the associated user if this decommission is tied to a leaver, so the seat is reclaimed on the next billing cycle rather than left consumed indefinitely. Log this action separately, as licence reconciliation is often audited independently of device cleanup.

#Verification
- Intune admin centre: device no longer listed under Devices, All devices.
- Autopilot device list: serial number absent.
- Entra ID: a
Get-MgDevicequery for the device name returns no result. - Hybrid AD, where applicable: computer object absent from the relevant organisational unit.
- Licence report: seat reassigned or returned to the available pool.
- Change ticket: closed with all screenshots and command output attached, referencing the original change record.
Cross-check the Entra ID audit log for the Delete device and Retire device events to confirm the actions were performed under your account and not duplicated by another administrator working the same batch. For recurring monthly refresh cycles, build a small dashboard query that lists devices marked for decommission against devices still appearing in Intune after seven days, so stalled offline devices surface automatically rather than being forgotten.
#Failure Modes
| Symptom | Likely cause | Fix |
|---|---|---|
| Reissued laptop fails Autopilot enrolment or reapplies the old user’s profile | Autopilot device identity not deleted in Step 5 | Delete the identity, then re-run the Autopilot profile sync from the OEM or reseller portal if the hardware hash needs refreshing |
| Wipe command accepted but device never actually resets | Device offline beyond the check-in window, action queued indefinitely | Confirm last check-in date; the action only fires on next contact, escalate for a manual power-on if urgent |
| Ghost device reappears in Entra ID days after deletion | Hybrid AD computer object not removed before the next Entra Connect sync | Remove the on-prem AD object first, then re-run the delete against Entra ID |
| Licence not reclaimed after wipe | Licence assignment is tied to the user object, not the device; wipe does not touch licensing | Explicitly unassign the licence from the user account |
| Wrong device wiped | Serial number transposition in the source spreadsheet | No data recovery is possible; escalate immediately, restore from backup The KBY Lexicon Backup A causally disconnected, point-in-time copy of system state, tagged with a consistency marker, that lets you recover from logical corruption or data loss independent of the source system's health.
|
#Rollback
Retire actions can be cancelled before the device checks in again. If the device is still online and you catch the mistake immediately, issue a corrective enrolment sync and reassign the original configuration profiles and compliance policy from the appropriate Entra ID group; the device will re-baseline on its next sync without loss of MDM history if it never actually processed the retire.
Wipe actions cannot be rolled back once the device has processed the command. That is the entire point of Wipe. There is no vendor-supported reversal. Your rollback plan for a mistaken Wipe is: re-enrol the device through Autopilot or manual enrolment, reassign the user’s configuration profiles and app assignments from your baseline group, and restore any user data from the last known OneDrive or backup snapshot. Document the incident regardless of whether data was recoverable, and note the timestamp of the original mistaken command for the post-incident review.
If you deleted the wrong Autopilot identity, re-register the device using the hardware hash captured from Get-WindowsAutoPilotInfo, upload it via the Intune admin centre or partner portal, then reassign the correct deployment profile before returning the device to the field.
#Operational Summary
The deliverable for this task is a fully decommissioned device with no trace remaining in Intune, Autopilot, Entra ID or on-prem AD, and a closed change ticket carrying command output, timestamps and before-and-after screenshots as evidence. Practise the full sequence on a single test device in a lab tenant before running it against a production batch: create a test managed device object, run all six steps, and confirm all four systems of record show the device as gone. That one successful dry run, captured in your own notes, is what tells your manager you are ready to run this against a real hardware refresh without supervision.
Treat the Retire-versus-Wipe decision as a data-protection decision, not a technical one. The moment you issue a Wipe, the outcome is final, so the discipline in this runbook is entirely about verifying identity and intent before the irreversible step, not about the mechanics of the API call itself. A newly hired engineer who can run this sequence cleanly, with evidence, on the first attempt has demonstrated exactly the kind of careful, verifiable operational discipline that endpoint management teams depend on.
#Learning Objectives
By the end of this runbook a junior administrator should be able to distinguish Retire from Wipe in operational terms, not just definitional ones, and select the correct action from device ownership type, physical state (returned, lost, stolen) and data-preservation status before any command is issued.
The administrator should be able to trace a single device through all four systems of record — Intune managed device, Windows Autopilot device identity, Entra ID device object, and hybrid on-prem AD computer object where applicable — and produce evidence that each has been cleared, rather than assuming success from a single console view.
A further objective is building the habit of a read-only confirmation query before every destructive call: retrieving the managed device record by serial number and cross-checking it against the asset register or ticket, so that the query itself becomes the rollback checkpoint rather than an afterthought.
Finally, the administrator should be able to explain, without notes, why a mistaken Wipe has no vendor-supported reversal while a mistaken Retire issued against a still-online device can often be corrected by re-baselining configuration and compliance assignments before the retire actually processes.
- Distinguish Retire, Wipe and selective wipe scenarios by device ownership and state
- Sequence Intune, Autopilot, Entra ID and hybrid AD cleanup so no system resurrects a stale record
- Capture verifiable evidence (query output, timestamps, screenshots) at each stage rather than relying on console memory
- Articulate the rollback boundary between correctable and irreversible actions before issuing a command
#Worked Example
Consider a lost corporate laptop reported by a manager on a Monday morning, with no confirmation yet on whether it was mislaid on-site or genuinely removed from the building. The correct first action under the decision table in this runbook is Retire, not Wipe, because Retire triggers a selective removal of corporate data the moment the device next contacts the service, whereas Wipe requires the device to be online to queue a full reset and offers no faster protection if the device is powered off by whoever holds it.
Before issuing Retire, the administrator runs the same confirmation query pattern described in Step 1 against the reported device name, checking SerialNumber and LastSyncDateTime specifically. A LastSyncDateTime more than a few hours old, combined with a ComplianceState still showing compliant, indicates the device has not yet been powered on since the report — this is the evidence that justifies escalating urgency in the change ticket rather than waiting for the standard batch window.
The Retire action is issued and the HTTP 204 response, timestamp and device ID are pasted into the ticket exactly as described for the Wipe example, because the evidence requirement does not change based on which action was chosen. Two days later the device is recovered intact and returned to IT. At this point the administrator re-queries the managed device record; if it still appears with a retire pending state because the device never checked in, the retire can be left to complete naturally, or the administrator can proceed directly to a full Wipe with keepUserData set to false once the device is confirmed physically in hand, converting the incident into a standard reissue.
This example illustrates the rollback boundary directly: because the Retire never processed (the device was offline throughout), there was nothing irreversible to undo, and the administrator's decision to move to Wipe once the hardware was recovered was a forward action, not a correction — the distinction that determines whether an incident report is required.
#Practice Exercise
Set up a single test device object in a lab tenant, following the same dry-run principle recommended in the Operational Summary. Assign it a fictitious serial number and device name that clearly marks it as non-production, for example LAB-TEST-0099, so it cannot be confused with a real asset during the exercise.
Run the Step 1 confirmation query against this test device and record the ManagedDeviceOwnerType, LastSyncDateTime and ComplianceState values before taking any action. This is your validation baseline — without it you cannot later prove the subsequent action changed the device's state as expected.
Issue a Retire against the test device and capture the response code and timestamp. Then attempt the Step 1 confirmation query again immediately afterwards; because Retire only processes on next check-in, the record should still be present, which is itself a useful validation that you understand the asynchronous nature of the action rather than a failure.
Delete the corresponding Autopilot device identity and Entra ID device object for the test device, capturing before-and-after evidence exactly as described in Steps 5 and 6. Then attempt to reverse the exercise: re-register the same serial number as a fresh Autopilot identity and confirm a new deployment profile can be assigned, demonstrating the recovery path documented in the Rollback section without needing a real incident to practise it.
Close the exercise by writing a one-paragraph note describing what evidence you would have been missing if you had skipped the baseline query in the first step, and submit this alongside your command output as proof of readiness before touching a production batch.
Evidence trail
Sources and verification
Primary documentation and external technical references used in this article.
Comments
Add a thoughtful note on Decommissioning Windows Devices in Intune: Retire, Wipe, Cleanup. Comments are checked for spam and held for moderation before appearing.
Related articles
Endpoint and Device Management
Deploying Windows Autopilot Device Preparation for New Hires
A hands-on runbook for configuring Windows Autopilot device preparation in Intune, covering registration, profiles, piloting, verification and rollback.
Enterprise IT Management
Engineering IT Management for Predictable Microsoft 365 Operations
How to stage, validate and safely roll back a scoped Exchange Online transport rule in Microsoft 365, using audit-only and pilot-enforce gates before any tenant-wide change.
Software Architecture
Designing a Verifiable Software Architecture Workflow with API
A bounded, evidence-led workflow for designing, validating and safely recovering an API-implemented software architecture, from contract-first layering to canary rollback.
Discover more
Graduate Learning
Ops Playbook
Lexicon Definitions
Learn More About KBY
About KBY
Learn about our mission, editorial standards, and commitment to trusted engineering knowledge.
Why Trust KBY
Explore the processes and policies that ensure our publications are accurate, useful, and responsible.
Newsletter
Get our latest editorial publications, research and practical insights sent directly to your inbox.
Was this useful?
Build practical engineering skills.
Receive new lessons, learning paths, practical exercises and early-career guidance.