Solved

Removing Old ActiveSync Devices Exchange 2010 Powershell

Posted on 2013-02-01
5
2,001 Views
Last Modified: 2013-02-06
Any suggestions on what I'm doing wrong with this script?

$Mailboxes = $null
$Devices = $null

$Mailboxes = Get-CASMailbox -Filter {HasActivesyncDevicePartnership -eq $true} -resultsize Unlimited

$Devices = $Mailboxes | %{Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity} | ?{($_.LastSuccessSync -ne $null) -and ($_.LastSuccessSync -le (Get-Date).AddDays(-14))}

$Devices | %{Remove-ActiveSyncDevice -identity $_.guid}

Open in new window



Error Message: "Cannot process argument transformation on parameter 'Identity'. Cannot convert the "8712635a-1ec2-4860-a654-121167c888d9" value of type "System.Guid" to type "Microsoft.Exchange.Configuration.Tasks.ActiveSyncDeviceIdParameter".
    + CategoryInfo          : InvalidData: (:) [Remove-ActiveSyncDevice], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Remove-ActiveSyncDevice"

However, when I use the GUID property tag in an individual "remove-activesyncdevice" cmdlet...it works.

Also, if I use the $_.Identity variable in place of the $_.GUID variable it works for some users but has trouble with others. Saying it cannot find the recipient
0
Comment
Question by:KevinKhanMCITP
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38858868
$_.guid var contain following value, which cannot be converted to type "Microsoft.Exchange.Configuration.Tasks.ActiveSyncDeviceIdParameter".

guid 
------
8712635a-1ec2-4860-a654-121167c888d9

Open in new window


Try
$Devices | %{Remove-ActiveSyncDevice -identity $_.guid.guid}
0
 

Author Closing Comment

by:KevinKhanMCITP
ID: 38859415
The script now runs as anticipated! Thank you! For future knowledge/readers why did that work?
0
 

Author Comment

by:KevinKhanMCITP
ID: 38859431
For readers,

This script finds All ActieSync Devices that have not successfully sync'd with the Exchange Server longer than 14 days only excluding the devices that have not reported back to the Exchange Server (leaving the lastsuccesssync field $null)
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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
A brief introduction to what I consider to be the best editor for PowerShell.
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…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

910 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

24 Experts available now in Live!

Get 1:1 Help Now