Solved

Removing Old ActiveSync Devices Exchange 2010 Powershell

Posted on 2013-02-01
5
2,166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
The viewer will learn how to dynamically set the form action using jQuery.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

688 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