Solved

Remove Outdated Mobile Devices from Exchange 2007

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
In this video we show how to create a Contact 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 Recipients >> Contact ta…

832 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