Exchange 2007 SP3: Piping "Identity" parameter from Get-CASMailbox output to Get-ActiveSyncDeviceStatistics

Per this article on Exchangepedia, I can run the following command to generate a list of accounts with ActiveSync partnerships:

Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -eq $true} | Select Identity

[the article uses Select Name, but I found Select Identity works as well]

What I'd like to do is pass the output from this command to Get-ActiveSyncDeviceStatistics, so I can determine the last time each user's 'ActiveSync-partnered' device authenticated against the server.  How do I do this?

The overall idea here is to figure out which ActiveSync partnerships are stale/unusued.
AA-in-CAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Use the following script.
$users = Get-CASMailbox -ResultSize "unlimited" -Filter {HasActiveSyncDevicePartnership -eq $true}
ForEach ($user in $users) { 
Get-ActiveSyncMailboxStatistics -Mailbox $user.name |
Export-csv "c:\ActiveSyncInfo.csv" -nti -append
}

Open in new window


Thats it.

Will.
0
AA-in-CAAuthor Commented:
Hi Will,

I tried the script, and Powershell threw an error saying Get-ActiveSyncMailboxStatistics isn't a valid cmdlet.  Also had to remove the -nti parameter for export-csv.  Thinking you meant Get-ActiveSyncDeviceStatistics, I tried that, but only one user's results appear in the .csv.  

I then manually tested Get-ActiveSyncDeviceStatistics against a different user, one whom I know has used their device recently, and sure enough, Powershell returned results to that effect.  

Why didn't this user (and the remaining ones) appear in the .CSV output?
0
Will SzymkowskiSenior Solution ArchitectCommented:
Sorry yes it should be Set not "get" my typo. What did not work? What is the exact error message?

Will.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

AA-in-CAAuthor Commented:
1)  Sorry, what should be "Set", not "Get"?

2)  That's the interesting thing.  There's no error message, with my corrections the script runs, but the CSV only contains output for a single user.  I checked the contents of $users in Powershell, and it output a list of the people with ActiveSync partnerships, as expected.  Noticed something, though:  the user that does appear in the CSV?  He's the last user in the list.
0
AA-in-CAAuthor Commented:
Here's the exact script I'm using, with modifications to make it run:

$users = Get-CASMailbox -ResultSize "unlimited" -Filter {HasActiveSyncDevicePartnership -eq $true}
ForEach ($user in $users) { 
Get-ActiveSyncDeviceStatistics -Mailbox $user.name |
Export-csv "c:\CAB\ActiveSyncInfo.csv"
}

Open in new window


3 changes in all:  Get-ActiveSyncMailboxStatistics became Get-ActiveSyncDeviceStatistics, and I removed "nti" and "append" as parameters of export-csv (they wouldn't run with those parameters, probably because this is Exchange 2007/Server 2008?).
0
Will SzymkowskiSenior Solution ArchitectCommented:
Sorry too many questions today getting mixed up. However it should be Get no set. I thought I was on a different question. -append should be used or it will overwrite your entries each time. I have a 2007 lab and the original script works fine for me.

Glad it is working for you!

Will.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.