Exchange 2010: Get the list of ActiveSync Devices


Copy and paste the script into Windows Powershell ISE (or Notepad if you like) and save it as ASDevices.ps1. Simply run this script on Exchange Shell with sufficient permissions. It will generate an CSV file on the script location named MobileDevics.csv.

<#

    Script Name: ASDevices.ps1

    Purpose: Generate a report of Active Sync Devices for all mailboxes.

    It lists     the user name (mailbox name), device name 

    (e.g., iPhone, Android) and device OS version number details. 

 

    Written By: Anand, the Awesome, Venkatachalapathy

    Written Date: November 4th 2012

#>

 

#Creating an empty array to store the device details

$ActiveSyncDevices = @()

 

#Get a list of Mailbox servers in the enterprise

$MbxServers = Get-MailboxServer

 

#for each mailbox server...

foreach ($server in $MbxServers)

{

  #for each mailbox in the mailbox server...

  foreach ($Mailbox in Get-Mailbox –Server $server.Name -Resultsize Unlimited) 

  {

    "Processing $($Mailbox.Identity)"

            

    #Get ActiveSync device details and store it in the array

    Get-ActiveSyncDeviceStatistics -Mailbox $Mailbox.Identity –ErrorAction SilentlyContinue | `

    Select DeviceFriendlyName, Devicetype, DeviceUserAgent | `

    ForEach-Object { $_ | Add-Member –MemberType NoteProperty -Name "MailboxIdentity" -value $Mailbox

    $ActiveSyncDevices += $_ }

  }

}

#cover teh arrary into csv file

$ActiveSyncDevices | Export-csv ./MobileDevices.csv

 

# - - - - - - - End of the Script - - - - - - - - -

Advertisements

6 thoughts on “Exchange 2010: Get the list of ActiveSync Devices

  1. Super. Can we add a filter where it generates it for last 30 days. I added where {$_.lastsuccesssync -gt ’11/01/2012′} but it exported it to a 0 kb csv

  2. Hello Anand,

    I have copied and pasted the above script, however getting an error on the below lines
    #Get a list of Mailbox servers in the enterprise

    $MbxServers = Get-MailboxServer

    Could you please email me the proper script, we are having a parent and child domain scenario. in my domain i only have two cas server.

    so could you please help me in getting the list of users who are using Apple devices (iPhone & iPad)
    Also I am able to find the list by the below command

    $devices = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like “CAS_{*”}
    $devices | foreach-Object {Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity | Select-Object DeviceFriendlyName,Identity,DisplayName,DeviceType,DeviceUserAgent,FirstSyncTime,LastSuccessSync}| Export-Csv d:\Aziz\_activesyncdevices.csv

    However I don’t want the field identity and how can identity replaced by email address or alias or display name.

    Thank in Advance

  3. I’ve found every iteration of how to export all devices to a CSV with all properties such as stated above and to the point of HTML report with pie chart but cannot find an example of a way to not get everyone. I need the ability for a team to populate a CSV (so IMPORT-CSV = XYZ), and only pull information on 10 people (example) versus return 50000 lines in Excel. No matter how I Google it, I only find ways to export all results which would take hours to refine down to say just these 50 people. There has to be a way to put SMTP addresses or user names or something to a CSV and foreach or pull that content in first then pipe to this command. I’ve checked Technet Scripting repository, tried different iterations trying to keep it simple but no matter what it returns everyone and everything.

    Has anyone else seen a need for this and point me in the right direction?

    Simple Example which is useless but returns the data I need.

    $UserList = Get-Content -Path “C:\Posh\Exchange\users.csv”

    Get-ActiveSyncDevice -Identity $Userlist | Select-Object UserDisplayName,FriendlyName,DeviceId,DeviceImei,DeviceOS,DeviceType,DeviceUserAgent,DeviceModel,DeviceAccessState,FirstSyncTime,lastsyncattempttime,lastsuccesssync | Export-CSV .\devicelist.csv -NoTypeInformation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s