Solved

Remove Outdated Mobile Devices from Exchange 2007

Posted on 2014-11-04
4
91 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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create a mailbox database 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 Servers >> Data…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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