In Intune, Entra, how can I find and delete orphaned devices, where the primary UPN is deleted? I also need to remove them from Autopilot. Has someone got a powershell script?
In Intune, Entra, how can I find and delete orphaned devices, where the primary UPN is deleted? I also need to remove them from Autopilot. Has someone got a powershell script?
You can use below script to find and delete orphaned devices with no primary UPN. First install these modules
check this document
Once you are connected, you should see something like below, same how they showed in the doc above.
and connect to Microsoft Graph for Intune as per this doc
And this will be your script-
You can remove these orphaned devices using their ObjectId
Similar way for Intune
And for autopilot
You can also refer to this document for reference