Forum Discussion
Device - Removal
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?
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
- almennnApr 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.