Link to home
Start Free TrialLog in
Avatar of AA-in-CA
AA-in-CA

asked on

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.
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

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.
Avatar of AA-in-CA
AA-in-CA

ASKER

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?
Sorry yes it should be Set not "get" my typo. What did not work? What is the exact error message?

Will.
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.
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?).
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial