Apr 18 2019 01:50 AM
hi Guys
Hope someone can help i am looking to removed retired devices from Intune and from Azure AD , i know they are a powershell script any advise would be great , even if you can point a script to remove devices from a exported CSV file that would be perfect
Thanks
Apr 18 2019 05:58 PM
@GrantBradley Hi Grant, have you tried using clean up rules? https://docs.microsoft.com/en-us/intune/devices-wipe#automatically-delete-devices-with-cleanup-rules
Apr 21 2019 12:36 PM
Hi @GrantBradley,
As @Ethan Stern said, device cleanup rules are a great way of getting rid of stale devices from Intune and devices which has been unenrolled are automatically deleted from Intune.
Another way of deleting stale devices is via Intune PowerShell SDK. Before using this you have to install the module,
Install-Module -Name Microsoft.Graph.Intune
To delete stale objects from AzureAD see this docs page:
https://docs.microsoft.com/sv-se/azure/active-directory/devices/manage-stale-devices
Apr 22 2019 07:24 AM
Hi Guys
thanks for the advise on the issues are they any other ways you know of bulk removing devices from azure i see i can remove it from intune via powershell or rule but are they anything for azure ad
Thanks
Grant
Apr 22 2019 07:41 AM
@GrantBradley Hi Grant, there are some cmdlets for removing from Azure AD- https://docs.microsoft.com/en-us/powershell/module/msonline/remove-msoldevice?view=azureadps-1.0
Is that what you were thinking of?
Apr 23 2019 01:10 AM
hi Ethan
i am already aware of that currently it is handy for removing one device but i am looking to remove in bulk if that is possible as devices have built over time and had not been removed
Thanks
Grant
Apr 23 2019 01:54 AM
Hi @GrantBradley,
You could do something like this in PowerShell to delete stale devices from AAD:
$dt = [datetime]’2018/12/12’
Get-MsolDevice -All -LogonTimeBefore $dt | select-object -Property DeviceId | foreach {$_.DeviceID} | foreach {$_.Guid} | Remove-MsolDevice -Force
This gets and deletes all devices with a timestamp older than specific date. You can see more information in the doc I provided earlier.
May 10 2022 12:01 PM