Solved

Remove Outdated Mobile Devices from Exchange 2007

Posted on 2014-11-04
4
87 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
A procedure for exporting installed hotfix details of remote computers using powershell
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now