Solved

Removing Old ActiveSync Devices Exchange 2010 Powershell

Posted on 2013-02-01
5
1,966 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
This video discusses moving either the default database or any database to a new volume.

708 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

20 Experts available now in Live!

Get 1:1 Help Now