I had an issue where several users that no longer work here still had active sync devices in AD for whatever reason so I needed to get rid of them.
Quick Google Search found this Technet thread
The long and short of it are these two lines that gather all the active sync devices that haven't checked in within the past 30 days and then removes them.
For my purposes I changed it 90 days the first time through, however I now run this script once monthly.
-- Powershell Start --
$DevicesToRemove = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-30")}
$DevicesToRemove | foreach-object {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}
-- Powershell End --
Now let's say the user doesn't have a mailbox on Exchange anymore.
You first have to temporarily recreate the mailbox
-- Powershell Start --
Enable-Mailbox -Identity:'OU/User'
-- Powershell End --
Then rerun the above script.
If you don't create the mailbox you get a can't find recipient error.
Then after the active sync devices are gone simply run
-- Powershell Start --
Remove-Mailbox -Identity:'OU/User'
-- Powershell End --
If for some reason you still can't remove the Active Sync devices you can open ADSI Edit and look for
CN=ExchangeActiveSyncDevices container under the user object
Then simply remove that.
Cheap Talk, throw your two cents in. Listen to what I have to say and you may actually enjoy yourself.
Subscribe to:
Post Comments (Atom)
I don't have a clue
I'm so very tired. It's almost all the time now.
-
It has now been 1 month since I got married to the most wonderful, beautiful, amazing girl in the world. I love her. I really do. I am ge...
-
Now I have been curious to know who has been reading this thing, besides the people I think are reading it. So I want you to contact me w/ ...
-
This may not sound like fun, but I think it is. Here is what you do. Go and find a CD you really like. Or make your own. Then find a roo...
No comments:
Post a Comment