If you’ve been asked to generate a report showing who in your organization uses ActiveSync devices, then you’ll know that it’s not altogether easy using the Exchange Management Console.
However, using the Exchange Management Shell it’s fairly trivial to accomplish with a couple of commands, and you can get some extra fancy information out at the same time. You’re exported data can then be exported using the CSV format and opened in Excel for further analysis or combining into reports.
Get a simple list of users with an ActiveSync device
Using the Exchange Management Shell, we can export a simple list of users with an ActiveSync device, then export that data to a CSV file.
The first line retrieves mailboxes with ActiveSync partnerships using Get-CASMailbox, and gets the full information via piping the output to Get-Mailbox.
$EASMailboxes = Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -eq $True -and DisplayName -notlike "CAS_{*"} | Get-Mailbox
The second line filters this output to just show the Username, Display Name and Email address, then exports that to a CSV file.
$EASMailboxes | Select SamAccountName,DisplayName,PrimarySMTPAddress | Export-CSV .\EASMailboxes.csv -NoTypeInformation
Once opened in Excel, you’ll see data like this, with a line for each user:
SamAccountName |
DisplayName |
PrimarySmtpAddress |
steve |
Steve Goodman |
Finally, if you’re after more detailed information, you can replace the second line and combine the Get-ActiveSyncDevice within the Select statement to get more detailed information. In the example line below, we can see the number of devices each user has:
$EASMailboxes | Select-Object SamAccountName, DisplayName, PrimarySMTPAddress, @{Name="EASDeviceCount";Expression={(Get-ActiveSyncDevice -Mailbox $_.Identity).Count}} | Export-CSV .\EASMailboxes.csv -NoTypeInformation
The “EASDeviceCount” is then reflected when the resulting CSV file is opened in Excel:
SamAccountName |
DisplayName |
PrimarySmtpAddress |
EASDeviceCount |
steve |
Steve Goodman |
4 |
And in two lines of PowerShell code, we’ve generated a report in two lines providing useful information.