Skip to content

Commit ee4d6c6

Browse files
wip
1 parent a79df2a commit ee4d6c6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

articles/active-directory/devices/manage-stale-devices.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,12 @@ Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt}
163163
164164
Before deleting any devices, back up any BitLocker recovery keys you may need in the future. There's no way to recover BitLocker recovery keys after deleting the associated device.
165165

166-
Using the same 90 day example we can pipe the output to delete the devices that have a logon time stamp over 90 days old.
166+
Building on the [disable devices example](#disable-devices) we look for disabled devices, now inactive for 120 days, and pipe the output to `Remove-AzureADDevice` to delete those devices.
167167

168168
```powershell
169-
$dt = (Get-Date).AddDays(-90)
170-
Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | Remove-AzureADDevice
169+
$dt = (Get-Date).AddDays(-120)
170+
$state = $false
171+
Get-AzureADDevice -All:$true | Where {($_.ApproximateLastLogonTimeStamp -le $dt) -and ($_.AccountEnabled -le $state)} | Remove-AzureADDevice
171172
```
172173

173174
## What you should know

0 commit comments

Comments
 (0)