When you delete a device in Intune first, it doesn't get deleted in Entra ID. In fact, it stays there as a Autopilot device and you can't delete it.
This is because the device is still registered as an Autopilot enrolled device in Intune and you need to delete that.
However, the enrollment list only contains, a few columns like the serial number, brand and model and you can't search using the computer name.
Of course it's easier to do it in the correct order to delete the device Autopilot Registration > Device in Intune > Device in Entra ID. But sometimes you forget or simply did not know.
To able to search for the Autopilot enrollment registration, you need the serial number of the device to delete, luckily you can still extract this from Entra ID using the API.
- Log in to Entra ID (https://entra.microsoft.com)
- Go to Devices > Overview > All devices and use the search bar to look for the device you want to delete. Then open the properties of the device
- Take note of the Device ID field
- Go to https://developer.microsoft.com/en-us/graph/graph-explorer and login with your admin credentials on the top right.
If this is your first time using it, you might need to give permissions first to allow the tool to look in your tenant - Make sure the query is set to GET and paste this command in the text box replacing the <device ID> with the ID found in step 3:
https://graph.microsoft.com/v1.0/deviceManagement/windowsAutopilotDeviceIdentities?$filter=azureActiveDirectoryDeviceId+eq+<deviceID>’
- Press Run Query
- You will get a response at the bottom containing information about the device including the serialnumber. Use that serial number to look up the registration in Intune and delete it