In order to get the list of users who are in Quarantine State for more than a month for a particular OU
Get-ActiveSyncDevice | Where {$_.UserDisplayName -match "Domain.com/OU" -and $_.DeviceAccessState -eq "Quarantined" -and $_.FirstSyncTime -lt (Get-Date).AddMonths(-1)} | ft UserDisplayName, DeviceModel, FirstSyncTime, DeviceAccessState, DeviceAccessStateReason -Auto
To Purge the list of users after running the above command, you need to pipe Remove-ActiveSyncDevice
Get-ActiveSyncDevice | Where {$_.UserDisplayName -match "Domain.com/OU" -and $_.DeviceAccessState -eq "Quarantined" -and $_.FirstSyncTime -lt (Get-Date).AddMonths(-1)} | Remove-ActiveSyncDevice -Confirm:$false
Get-ActiveSyncDevice | Where {$_.UserDisplayName -match "Domain.com/OU" -and $_.DeviceAccessState -eq "Quarantined" -and $_.FirstSyncTime -lt (Get-Date).AddMonths(-1)} | ft UserDisplayName, DeviceModel, FirstSyncTime, DeviceAccessState, DeviceAccessStateReason -Auto
To Purge the list of users after running the above command, you need to pipe Remove-ActiveSyncDevice
Get-ActiveSyncDevice | Where {$_.UserDisplayName -match "Domain.com/OU" -and $_.DeviceAccessState -eq "Quarantined" -and $_.FirstSyncTime -lt (Get-Date).AddMonths(-1)} | Remove-ActiveSyncDevice -Confirm:$false
No comments:
Post a Comment