Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Removal of Stale ActiveSync Devices

Posted on 2016-09-27
13
Medium Priority
?
552 Views
Last Modified: 2016-10-03
How can we get the list of Stale ActiveSync Devices list in CSV and how to remove those


Please suggest
0
Comment
Question by:Addy Nadia
13 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 41817822
Following script will Export the device details which is not in sync for last 30 days to csv..
$StaleDevices = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | ?{$_.LastSuccessSync -le (Get-Date).AddDays("-30")}
$StaleDevices | Export-csv C:\ActiveSyncDevicereport.csv -nti

Open in new window

After that you can run the following line of code to remove the device..
#To remove 
$StaleDevices | % {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}

Open in new window

0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41817838
Hello subsun,

As per 1st script you gave, i need to run as it is ? i hope this will only give device List which are stale. i need the one for 90 days

Thanks,
Andy
0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41817839
i have exchange 2013, i think Get-MobileDevice will work.. not sure. can you check
0
Independent Software Vendors: 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!

 
LVL 40

Expert Comment

by:Subsun
ID: 41817884
Yes for Exchange 2013 it's Get-MobileDevice & Remove-MobileDevice
Try..
$StaleDevices = Get-CASMailbox -ResultSize unlimited –Filter {(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike “cas_*”) -AND (name -notlike “DiscoverysearchMailbox*”)} | % {Get-MobileDeviceStatistics -Mailbox $_.Identity | Where-Object {$_.LastSuccessSync -le ((Get-Date).AddDays(“-30”))}}

$StaleDevices | Export-csv C:\ActiveSyncDevicereport.csv -nti

Open in new window

To Remove..
$StaleDevices | Remove-MobileDevice

Open in new window

0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41817917
But when i am running this command,

i am getting lot of error for specific OU type, that could find the user .something like that with name of user
But i have seen it is pointing to one OU, where we store our Disabled accounts, i mean who left the company.

do you have any suggestion to add that particular OU in exception

Thanks,
Andy
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41817936
For example if "corp.domain.com/Admin/IT/Disabled Users/" is the disabled user OU and you want to exclude devices from that OU, then try..
$StaleDevices = Get-CASMailbox -ResultSize unlimited –Filter {(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike “cas_*”) -and (name -notlike “DiscoverysearchMailbox*”)} | % {Get-MobileDeviceStatistics -Mailbox $_.Identity | ? {?{$_.Identity -notmatch "corp.domain.com//Admin//IT//Disabled Users//"} -and $_.LastSuccessSync -le ((Get-Date).AddDays(“-30”))}}

$StaleDevices | Export-csv C:\ActiveSyncDevicereport.csv -nti

Open in new window

If it does not work post the error..
0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41818405
Can you please suggest any article or any of your comments .. what are the benefits of removing the stale active sync devices from the environment

Thanks,
Andy
0
 
LVL 5

Author Comment

by:Addy Nadia
ID: 41818427
i am getting below error when running first command

Cannot bind parameter 'Filter' to the target. Exception setting "Filter":
"Invalid filter syntax. For a description of the filter parameter syntax see
the command help.
"(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike "cas_*") -AND
(name -notlike "DiscoverysearchMailbox*")" at position 65."
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41818477
i am getting below error when running first command
Try..
$StaleDevices = Get-CASMailbox -ResultSize unlimited –Filter {HasActiveSyncDevicePartnership -eq $true} | % {Get-MobileDeviceStatistics -Mailbox $_.Identity | ? {?{$_.Identity -notmatch "corp.domain.com//Admin//IT//Disabled Users//"} -and $_.LastSuccessSync -le ((Get-Date).AddDays(“-30”))}}

Open in new window


Can you please suggest any article or any of your comments .. what are the benefits of removing the stale active sync devices from the environment
Removing the stale devices will help keep your Exchange environment neat and tidy, Some do it for security audit compliance.

Also Exchange throttling policies by default limits users to a maximum number of device relationships and concurrent devices. Users may change devices or simply upgrades the firmware on their Android device, all this will end up creating new device relationship.  Exchange doesn’t have any inbuilt process to remove older devices immediately. So it's better to clean it up regularly.
0
 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 41818541
$StaleDevices = Get-CASMailbox -ResultSize unlimited –Filter {HasActiveSyncDevicePartnership -eq $true} | foreach-object {Get-MobileDeviceStatistics -Mailbox $_.Identity | Where-Object {Where-Object{$_.Identity -notmatch 'corp.domain.com//Admin//IT//Disabled Users//'} -and $_.LastSuccessSync -le ((Get-Date).AddDays('-30'))}}
$StaleDevices | Export-csv C:\ActiveSyncDevicereport.csv -nti

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 41818596
Just noticed some syntax error in my code (ID: 41818477). Here is corrected one..
$StaleDevices = Get-CASMailbox -ResultSize unlimited –Filter {HasActiveSyncDevicePartnership -eq $true} | % {Get-MobileDeviceStatistics -Mailbox $_.Identity | ?{$_.Identity -notmatch "corp.domain.com//Admin//IT//Disabled Users//" -and $_.LastSuccessSync -le ((Get-Date).AddDays(“-30”))}}
$StaleDevices | Export-csv C:\ActiveSyncDevicereport.csv -nti

Open in new window

0
 
LVL 16

Expert Comment

by:Ajit Singh
ID: 41823291
Removing stale Exchange Active Sync Device is a general housekeeping matter, along with security best practices also removing stale devices keeps the system database lean and running faster.

Get help from this blog to Remove Old ActiveSync Devices Exchange Server 2010 / 2013 / 2016 / 0365: http://www.ntweekly.com/?p=11122

How to delete mobile device in exchange 2013:
https://community.spiceworks.com/topic/703956-how-to-delete-mobile-device-in-exchange-2013

Hope this helps!
1
 
LVL 5

Author Closing Comment

by:Addy Nadia
ID: 41825959
Thanks
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

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

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
In this video we show how to create an Accepted Domain 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 >> Ac…
To show how to generate a certificate request 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 >> Certificates…

885 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