Forum Discussion
GrantBradley
Apr 18, 2019Copper Contributor
Device - Removal
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 scri...
GrantBradley
Apr 23, 2019Copper Contributor
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
almennn
Apr 23, 2019Brass Contributor
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.