Decommissioning Windows Devices in Intune: Retire, Wipe, Cleanup
Decide between Retire and Wipe for a Windows device in Intune, then remove the Autopilot identity and hybrid AD object in order so re-enrolment does not fail.

Quick answer
A safe Windows decommission removes corporate access and data without losing the identifiers needed for audit or reuse. Confirm ownership first, choose Retire or Wipe deliberately, verify the result, and only then remove stale Intune, Entra ID and Autopilot records.
Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.
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
Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
Taking an old laptop out of service looks like a routine ticket, which is exactly why it goes wrong. A wipe cannot be undone, and records cleaned up in the wrong order can trip up the next person who sets the device up. The right action, the order for removing each record and the proof that the device is gone from every system all need to be settled before you start.
Choose Retire for supported selective corporate-data removal and Wipe for a factory reset, then verify each asynchronous action before cleaning up records in Microsoft’s order: delete the device from Intune, then deregister it from Windows Autopilot, then, for hybrid-joined devices, delete the on-premises AD computer object.
If the device is registered with Windows Autopilot, don’t delete its Entra ID device object by hand unless a specific scenario requires it, because deleting it can cause enrolment failures. Device ownership, platform, and wipe options change the exact outcome, so confirm the current Microsoft action table and serial number before any destructive request.
Related KBY guidance: verify BitLocker recovery-key escrow before decommissioning.
#Why a routine decommission can still go wrong
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: a device leaves the organisation for good (recycled, sold or returned to the vendor) but its Windows Autopilot device identity is never deregistered, so it stays registered to your tenant and still goes through your Autopilot deployment when its next owner sets it up.
Third: on a hybrid-joined estate, you clean up Intune but leave the on-prem AD computer object in place, so Entra Connect keeps resyncing a stale device record 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), delete the device from Intune, deregister it from Windows Autopilot, clean up any hybrid AD remnants, and produce verifiable evidence that the device is retired from every system of record. Follow it step by step; do not skip the confirmation steps because the ticket seems routine.
#Roles, Graph scopes and other prerequisites
- An Entra ID account assigned the Intune Administrator role, or a custom Intune RBAC role granting the Managed devices/Delete, Remote tasks/Wipe and Remote tasks/Retire permissions, plus Managed devices/Read.
- 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","DeviceManagementServiceConfig.ReadWrite.All"
2
3Get-MgDeviceManagementManagedDevice -Filter "deviceName eq 'FIN-LT-0231'" | Select-Object Id, DeviceName, SerialNumber, UserPrincipalName, ManagedDeviceOwnerType, EnrolledDateTime, LastSyncDateTime, ComplianceState#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. For lost or stolen devices, record that the data cannot be preserved and that the owner has accepted this.
For BYOD devices, which go through Retire only, confirm the user has been told that corporate data and the management profile will be removed. 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 a scripting mistake against the wrong device group can reach enough devices to justify a second pair of eyes on the filter logic before execution. Pilot the sequence on a single device before running a batch.
#Step 4: Retire or Wipe the device
Retire and Wipe are not interchangeable. Use the decision table below before issuing either command, and check the exact effect for the device’s platform and join type in Microsoft’s Intune remote actions documentation.

| Scenario | Action | Effect |
|---|---|---|
| Leaver, corporate device returns for reissue | Wipe (keepUserData:false) | Factory reset that removes local data. Whether enrolment data is kept depends on the keepEnrollmentData setting (see below) |
| BYOD, user leaving the programme | Retire | Removes corporate data and management profile; personal data is left |
| Corporate Microsoft Entra joined device you intend to Retire | Retire (only if the documented effect is what you want) | Different from BYOD: Microsoft documents that Retire removes the device’s Entra ID record (unless it is registered in Autopilot) and, with BitLocker, removes key protectors. Back up first (see below) |
| Device replaced under warranty, returned to vendor | Wipe | Ensures no residual corporate data leaves the estate |
| Device stolen or lost | Wipe | Wipe is for devices that need to be securely erased if lost or stolen. Don’t Retire instead: on a Microsoft Entra joined device protected by BitLocker, Retire removes the key protectors and suspends BitLocker on the OS volume |
Before you Retire a Microsoft Entra joined device, back up its BitLocker recovery key and local administrator account credentials. Both are critical data that may be lost in the process, and a Retire removes the device’s Entra ID record unless the device is registered in Autopilot.
For Wipe, keepEnrollmentData and keepUserData control what survives. With keepEnrollmentData set to false, the enrolment state and associated management data are not retained, so the device will need to be enrolled again; with keepUserData set to false, user data is not kept. Confirm the exact behaviour for your platform in Microsoft’s documentation before choosing values.
First run the read-only checks and confirmation, then issue only one of the two actions below. Never run both against the same device.
1# Use the serial number confirmed in Step 1 (replace with the value from your asset register)
2$serial = 'PF3XK912'
3$found = @(Get-MgDeviceManagementManagedDevice -Filter "serialNumber eq '$serial'")
4if ($found.Count -ne 1) { throw "Expected exactly one managed device for serial $serial, found $($found.Count). Stop." }
5$deviceId = $found[0].Id # must equal the Id recorded in Step 1
6Write-Host "Target: $($found[0].DeviceName) / $($found[0].SerialNumber) / $deviceId"
7if ((Read-Host 'Type YES to proceed') -ne 'YES') { throw 'Cancelled by operator.' }Option A: Wipe (run this block only if the decision is Wipe)
1Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/$deviceId/wipe" -ContentType 'application/json' -Body (@{ keepEnrollmentData = $false; keepUserData = $false } | ConvertTo-Json) -StatusCodeVariable status
2$statusOption B: Retire (run this block only if the decision is Retire)
1Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/$deviceId/retire" -StatusCodeVariable status
2$statusCheck the action state in Intune, and if the device is offline, note this in the ticket and set a follow-up reminder rather than assuming completion.
Do not delete the device record or the Autopilot identity until the Intune action state shows the wipe or retire as complete; deleting earlier can leave data on a device that never processed the action.
#Step 5: Remove the Windows Autopilot device identity
First, delete the device from Intune. Microsoft’s order is fixed: a device has to be deleted from Intune before it can be deregistered from Windows Autopilot. Confirm first that the wipe or retire action state is complete. In the Intune admin centre, go to Devices, then Windows, select the device, note its serial number, and select Delete. Only then remove the Autopilot identity below.
Deregister a device whenever it permanently leaves the organisation, for example at the end of its life or when it leaves for repair. If the device is only being reissued internally, keep the registration and skip the deletion below, but unassign any user assigned to its Autopilot record. Deregistration also unassigns any assigned user before the Autopilot record is deleted, as the script does.
1$serial = 'PF3XK912' # must match the serial number recorded in Step 1
2# Precondition: the managed device must already be gone from Intune
3if (@(Get-MgDeviceManagementManagedDevice -Filter "serialNumber eq '$serial'").Count -ne 0) { throw 'Device still exists in Intune. Delete it first. Stop.' }
4$autopilotDevice = @(Get-MgDeviceManagementWindowsAutopilotDeviceIdentity -Filter "contains(serialNumber,'$serial')" | Where-Object { $_.SerialNumber -eq $serial })
5if ($autopilotDevice.Count -ne 1) { throw "Expected exactly one Autopilot identity for $serial, found $($autopilotDevice.Count). Stop." }
6# Microsoft's order: unassign any assigned user, then delete the Autopilot record
7if ($autopilotDevice[0].UserPrincipalName) { Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/deviceManagement/windowsAutopilotDeviceIdentities/$($autopilotDevice[0].Id)/unassignUserFromDevice" }
8Remove-MgDeviceManagementWindowsAutopilotDeviceIdentity -WindowsAutopilotDeviceIdentityId $autopilotDevice[0].Id#Step 6: Clean up hybrid AD remnants, and leave an Autopilot device’s Entra ID object alone
If the device is registered with Windows Autopilot, don’t delete its Entra ID device object by hand. For Microsoft Entra joined devices, no further steps are needed after deregistering the device from Windows Autopilot through Intune, and manual deletion from Entra ID should be avoided unless a specific scenario requires it: the Autopilot deployment process relies on that object, and deleting it can cause enrolment failures. The object can remain in Entra ID after deregistration.
For a device that isn’t registered with Autopilot, the guidance is different: after the action, you might also want to remove its record from Entra ID. Managing stale devices in Microsoft Entra ID covers how to do that. If the action was a Retire and the device is Microsoft Entra joined, the Retire itself removes that record, which is why Step 4 has you back up the BitLocker recovery key and local administrator credentials before retiring it.
If the device is Microsoft Entra hybrid joined, delete its computer object from on-premises Active Directory so that it isn’t resynced to Entra ID. Before you do, export any BitLocker recovery key for the device that is stored in Active Directory and that you might still need.
Recovery information is stored in a child object of the computer object itself, and old recovery keys aren’t removed automatically from AD DS unless the computer object is deleted. Fetch and verify the object first, then preview the deletion with -WhatIf:
1$comp = Get-ADComputer -Identity "FIN-LT-0231" -Properties DistinguishedName, Created
2$comp | Format-List Name, DistinguishedName, Created # confirm this is the device from Step 1
3
4# Review child objects (such as BitLocker recovery information) before deleting
5Get-ADObject -SearchBase $comp.DistinguishedName -SearchScope OneLevel -Filter *
6
7# If there are no child objects:
8Remove-ADComputer -Identity $comp -WhatIf
9# If the preview is correct, run without -WhatIf and answer the prompt.Remove-ADComputer deletes leaf objects only. If child objects exist, export the recovery keys you need first, then use Remove-ADObject, which has the -Recursive parameter, and preview it with -WhatIf before running it for real:
1Remove-ADObject -Identity $comp.DistinguishedName -Recursive -WhatIf
2# If the preview is correct, run without -WhatIf and answer the prompt.Finally, 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.

#Verify the decommission in each console
- Intune admin centre: device no longer listed under Devices, All devices.
- Autopilot device list: serial number absent.
- Entra ID: for an Autopilot device, the object may still be listed; it can remain after deregistration. Don’t delete it by hand (Step 6). For a hybrid-joined device, it shouldn’t be resynced once the on-prem computer object is gone.
- 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 Intune audit logs (Tenant administration, Audit logs) for the retire or wipe action, and the Entra audit log for any device deletion 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.
#When a decommission goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| A device that has left the organisation still goes through your Autopilot deployment | Autopilot device identity not deregistered in Step 5 | Confirm the device is deleted from Intune, then deregister the identity (Step 5) |
| 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 |
| Stale hybrid device keeps reappearing in Entra ID | Hybrid AD computer object not removed, so Entra Connect resyncs it | Export any BitLocker recovery key stored under the on-prem AD computer object that you might still need, then delete the object (Step 6). For an Autopilot device, don’t delete the Entra ID object by hand |
| 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 from the device; escalate immediately, restore user data from backup if one exists, document as an incident |
#Recovering from a mistaken Retire, Wipe or deletion
Treat a submitted Retire action as asynchronous but not safely reversible. Confirm the device action state in Intune; do not promise cancellation. If Retire has processed, restore management only through the approved enrolment path and reapply the device baseline. If the device has not checked in, escalate to the Intune owner before issuing any competing action.
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.
A Wipe sent with keepEnrollmentData set to false does not retain enrolment data, so the device must be enrolled again; a Wipe with keepUserData set to false removes user data, which can only come back from OneDrive or a backup.
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.
#What a finished decommission looks like
The deliverable for this task is a fully decommissioned device (deleted from Intune, deregistered from Windows Autopilot and, where hybrid-joined, removed from on-prem AD, with an Autopilot device’s Entra ID object left in place rather than deleted by hand) 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: enrol a lab machine or virtual machine and register it for Autopilot, run all six steps, and confirm Intune, Autopilot and, where applicable, on-prem AD 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 of each one’s state (removed from Intune, Autopilot and on-prem AD, with an Autopilot device’s Entra ID object left in place rather than deleted by hand) instead of 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 submitted Retire cannot be reliably cancelled, and recovery means re-enrolling the device.
- Distinguish Retire, Wipe and selective wipe scenarios by device ownership and state
- Sequence Intune deletion, Autopilot deregistration and hybrid AD cleanup in Microsoft’s order, 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
#A practice run on a lab device
Use a real or virtual machine enrolled in a lab tenant, and register its hardware hash for Windows Autopilot, following the same lab dry run recommended above. Give it a 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 test device from Intune, then deregister its Autopilot identity, capturing before-and-after evidence exactly as described in Step 5. Because it’s an Autopilot device, leave its Entra ID device object in place, as Step 6 explains. 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 recovery section above 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.
About this page
Credited to
Dates
Published
Corrections
- : Steps 4 and 6 gained the same note about what a Retire does to an Entra-joined device, and the hybrid Remove-ADComputer step now says to back up any BitLocker recovery information held in Active Directory first. That step is marked untested. Details
- : The earlier correction told readers never to delete any device's Entra ID object by hand. That advice is now limited to devices registered in Windows Autopilot, which is what Microsoft's guidance covers. Details
- : The guide told readers to delete the device's Entra ID object by hand, to deregister it from Autopilot without first deleting it from Intune, and to Retire a lost or stolen device. It now deletes the device from Intune first, names Wipe for lost or stolen devices, and no longer deletes the Entra ID object by hand. Details
Found this useful? Follow KBY for more like it.
Recommended reading
More from KBY that goes with this article.


- Microsoft Intune error
0x800705b4: Autopilot self-deploying mode fails at Securing your hardware
2 min read
Related articles
Endpoint and Device Management
Working Out Why an Intune App Install Failed on One Windows Device
An Intune app failed on one Windows device? Read Device install status and Managed Apps, then match the failure to a stage of the Win32 install flow.
ReadEnterprise IT Management
Part 6: Reset, Retire and Reuse Windows Autopilot Devices Safely in Intune
Autopilot Reset, Wipe and Fresh Start compared, a handover to a new user, and the safe order for retiring a device.
ReadSecurity
Device Code Phishing: Rogue Entra Devices in 305 Organisations Survive a Password Reset
Huntress found 468 rogue Entra ID device registrations in 305 organisations. A password reset does not remove them. How to find the devices and block the device code flow.
ReadDiscover more
Graduate Learning
- TutorialAuditing Privileged Role Assignments in Microsoft Entra ID with Read-Only Microsoft Graph PowerShell
- TutorialWorking Out Why an Intune App Install Failed on One Windows Device
- TutorialListing Disabled Users in Microsoft Entra ID with Read-Only Microsoft Graph PowerShell
- TutorialRevoking a User’s Sessions in Microsoft Entra ID After a Suspected Account Compromise
Ops Playbook
- PlaybookInstall containerd on Autopilot Laptops Without Rebooting Mid-Provisioning
- PlaybookReplace Remote-Control Sessions With Intune Device Query for First-Line Windows Triage
- PlaybookProve Your Entra ID Break-Glass Accounts Still Work With a Quarterly Sign-In Drill
- PlaybookFind the Windows Apps That Crash Most With Intune’s Application Reliability Report
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Build practical engineering skills.
Receive new lessons, learning paths, practical exercises and early-career guidance.
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.