This post is also available in: Polish
Exchange 2010 Get list of mobile devices with activesync for user:
Sometimes we want to know what kind of mobile devices uses ours users.
If we want to check only one user it’s not a problem. We can use Powershell cmdlet:
Get-ActiveSyncDeviceStatistics
If we want to know what activesync devices uses John Smith we need to run:
Get-ActiveSyncDeviceStatistics -Mailbox "John Smith" | fl
or if we want to specify the output:
Get-ActiveSyncDeviceStatistics -Mailbox "John Smith" | Select-Object @{n="Mailbox";e={$mailbox}}, LastSuccessSync, Status, DeviceID, DeviceType, DeviceUserAgent, DeviceModel, DeviceIMEI, DeviceOS
Exchange 2010 get list of all users activesync devices
Unfortunatelly mostly we want to get list of all mobile devices used by users.
This is not so easy because every user can use more than one mobile device: cell phones, tablets and other devices.
If we run Get-ActiveSyncDeviceStatistics for some user, we can get many devices, to get only current devices we have to check LastSuccessSync. This property tell us when was the last time when mobile device has connected to user mailbox.
So if we want to get list of all activesync devices used in our Exchange 2010 environment you can use below script:
Set-AdServerSettings -ViewEntireForest $True Function New-Array {,$args} $Report = new-array $file_out = "D:\Scripts\mobile_devices.csv" $mbx = Get-CASMailbox -ResultSize Unlimited | ?{$_.HasActiveSyncDevicePartnership} $mbx | ForEach-Object { $mailbox = $_.Name $PrimarySMTPAddress = $([string]$_.PrimarySMTPAddress) $stats = Get-ActiveSyncDeviceStatistics -Mailbox $PrimarySMTPAddress if($stats){ foreach ($dev in $stats){ $device = New-Object System.Object $device | Add-Member -type NoteProperty -name Mailbox -value $mailbox $device | Add-Member -type NoteProperty -name LastSuccessSync -value $dev.LastSuccessSync $device | Add-Member -type NoteProperty -name DeviceID -value $([string]$dev.DeviceID) $device | Add-Member -type NoteProperty -name DeviceType -value $dev.DeviceType $device | Add-Member -type NoteProperty -name DeviceUserAgent -value $dev.DeviceUserAgent $device | Add-Member -type NoteProperty -name DeviceModel -value $dev.DeviceModel $device | Add-Member -type NoteProperty -name DeviceIMEI -value $([string]$dev.DeviceIMEI) $device | Add-Member -type NoteProperty -name DeviceOS -value $dev.DeviceOS $Report += $device } } } $Report | Export-Csv $file_out -NoType
First in script you will get all CasMailboxes and write them to $mbx
If you want to check only mailboxes on specified mailbox server you need to modify this line to:
$mbx = Get-CASMailbox -ResultSize Unlimited | ?{$_.HasActiveSyncDevicePartnership -and $_.ServerName -like "some-server"}
Next when we get list of all mailboxes, we run for each of them Get-ActiveSyncDeviceStatistic and assign result to $stats
We check $stats, if it’s empty ($null) then we don’t want to save ActiveSync Device Statistics to our Report. We want to get only mailboxes with active mobile devices.
When all mailboxes are checked, then result of this script will be saved to the .csv file.
This script is a life saver. Thanks so much!
I want to get the information for the list of users with the Mobile devices connected .
Thanks
Great, I was searching for a long time for a script like this…
Thanks