Sunday, November 4, 2012

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 - - - - - - - - -

No comments:

Post a Comment

Followers

hit counter