Solved

Remove Outdated Mobile Devices from Exchange 2007

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exch2013 changed to new one 6 19
No Exchange 2013 servers detected 3 28
Need some help with powershell script 5 34
Can't send to contact 6 39
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
A procedure for exporting installed hotfix details of remote computers using powershell
In this video we show how to create an Address List 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 Organization >> Ad…
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…

939 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

3 Experts available now in Live!

Get 1:1 Help Now