Solved

Remove Outdated Mobile Devices from Exchange 2007

Posted on 2014-11-04
4
92 Views
Last Modified: 2014-11-18
I would like to run a command to remove all mobile devices in the Exchange Server which have not synced in > 30 days. Is there a way in shell to do this without having to enter all of the user names?
0
Comment
Question by:Thom Gann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 40450729
$OldDevices = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-30")}
$OldDevice s| foreach {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}

Open in new window


Ref: https://social.technet.microsoft.com/Forums/exchange/en-US/95ca6537-0c74-4c36-b19b-ec647e733722/remove-staleold-active-sync-devices-from-all-mailboxes
0
 
LVL 37

Accepted Solution

by:
Jamie McKillop earned 500 total points
ID: 40450756
Hello,

Try this:

$now = [DateTime]::get_Now()
Get-CASMailbox -ResultSize unlimited | % {
	Get-ActiveSyncDeviceStatistics -mailbox $_.primarysmtpaddress.tostring() | % {
		If ($_.lastsuccesssync -ne $null) {
			$delta = $now - $_.lastsuccesssync
		} Else {
			$delta = 31
		}
		if ($delta.Days -gt 30) {
			Remove-ActiveSyncDevice -Identity $_.identity -confirm:$false
		}
	}
}

Open in new window


-JJ
0
 

Author Closing Comment

by:Thom Gann
ID: 40450886
Worked like a champ! Thank you!
0
 

Author Comment

by:Thom Gann
ID: 40450894
@ Rajitha Chimmani - When I tried your command, I got an error, "The term 'Get-ActiveSyncDevice' is not recognized as the name of a cmdlet, function, script file, or operable program... Thank you for the help though.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question