Support
 
PhoneGet Quote
 
Support
 
US Sales: +1 888 720 9500
US Support: +1 844 245 1108
Intl: +1 925 924 9500
Aus: +1 800 631 268
UK: 0800 028 6590
CN: +86 400 660 8680

Direct Inward Dialing: +1 408 916 9890

 
 

PowerShell script to fetch ActiveSync statistics for Office 365 mailboxes

The Office 365 Admin Center doesn’t provide complete information about ActiveSync-enabled mobile devices. This is the reason most IT admins rely on PowerShell scripts to obtain the in-depth details they require. But the process can involve cumbersome code. As an example, below are the PowerShell scripts needed to acquire ActiveSync statistics.

Step 1: Connecting to Exchange Online

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

This PowerShell cmdlet imports the Exchange Online cmdlets to the local Windows PowerShell session.

Step 2: Retrieving all mailboxes

$mailboxes = Get-Mailbox -ResultSize unlimited 

This PowerShell cmdlet fetches all mailboxes in the organization.

Step 3: Filtering the output.


foreach ($mailbox in $mailboxes)
{
$devices = Get-ActiveSyncDeviceStatistics -Mailbox $mailbox.samaccountname
if ($devices) {
foreach ($device in $devices){
$deviceobj = New-Object -TypeName psobject
$deviceobj | Add-Member -Name DisplayName -Value $mailbox.DisplayName -MemberType NoteProperty
$deviceobj | Add-Member -Name UPN -Value $mailbox.UserPrincipalName -MemberType NoteProperty
$deviceobj | Add-Member -Name Status -Value $device.Status -MemberType NoteProperty
$deviceobj | Add-Member -Name DeviceID -Value $device.DeviceID -MemberType NoteProperty
$deviceobj | Add-Member -Name DeviceEnableOutboundSMS -Value $device.DeviceEnableOutboundSMS -MemberType NoteProperty
$deviceobj | Add-Member -Name DeviceMobileOperator -Value $device.DeviceMobileOperator -MemberType NoteProperty
$deviceobj | Add-Member -Name DeviceAccessState -Value $device.DeviceAccessState -MemberType NoteProperty
$deviceobj | Add-Member -Name DeviceActiveSyncVersion -Value $device.DeviceActiveSyncVersion -MemberType NoteProperty
$deviceobj | Add-Member -Name FirstSyncTime -Value ($device.FirstSyncTime).ToString("yyyy-MM-dd HH:mm:ss") -MemberType NoteProperty
$deviceobj | Add-Member -Name LastPolicyUpdateTime -Value ($device.LastPolicyUpdateTime).ToString("yyyy-MM-dd HH:mm:ss") -MemberType NoteProperty
$deviceobj | Add-Member -Name LastSyncAttemptTime -Value ($device.LastSyncAttemptTime).ToString("yyyy-MM-dd HH:mm:ss") -MemberType NoteProperty
$deviceobj | Add-Member -Name LastSuccessSync -Value ($device.LastSuccessSync).ToString("yyyy-MM-dd HH:mm:ss") -MemberType NoteProperty
$deviceobj | Add-Member -Name NumberOfFoldersSynced -Value $device.NumberOfFoldersSynced -MemberType NoteProperty

This code fetches the mailboxes' ActiveSync connected devices, and shows the associated username, display name, email address, number of devices each user has, and more. The results are then exported to a CSV file.

O365 Manager Plus' preconfigured ActiveSync reports to the rescue

IT admins are often overwhelmed by the sheer volume of the Excel spreadsheets or CSV files generated to micromanage  each device configured with Office 365. But there is a more efficient process.

O365 Manager Plus, ManageEngine’s Office 365 reporting, auditing, monitoring, and management tool, comes with more than 700 preconfigured reports on Azure AD, Exchange Online, Skype for Business, OneDrive for Business, Yammer, and other Office 365 services. These can assist IT admins in effortlessly monitoring users and mailboxes in bulk.

O365 Manager Plus' mobile device reports help IT admins keep track of all the Office 365 ActiveSync-enabled mobile devices by mapping users' mobile devices with their corresponding Office 365 mailboxes and policies. The reports can be scheduled to run at fixed intervals, emailed to administrators, and exported to CSV, XLS, PDF, or HTML formats.

Some of O365 Manager Plus' reports for fetching ActiveSync statistics include:

  1. Mobile Devices
  2. Mobile Devices by OS
  3. Mobile Devices by Policy
  4. Mobile Devices by Manufacturer
  5. Mobile Devices by Client
  6. Active Mobile Devices
  7. Device Policy Application Status
  8. Folders Synchronized Per Device
  9. Device By Access State
  10. Inactive ActiveSync Devices
  11. ActiveSync Enabled Mailboxes

Advantages of O365 Manager Plus' reporting:

  • Advanced filters: Use attribute and condition-based filters to obtain the data required without running complex PowerShell scripts.
  • Reports on historical data: PowerShell cmdlets can only retrieve data at least seven days old and no older than 180 days. But O365 Manager Plus’ reports can fetch all data from the date of installation.
  • Customizable dashboard: O365 Manager Plus’ dashboard is customizable. Add reports in graph formats to take a quick peek at the mail traffic summary, top email senders and receivers, client device usage, and more. This dashboard can be embedded in any of the webpages to enable constant monitoring.
  • Report scheduler: Schedule reports to be generated at regular intervals to reduce the overhead of generating them manually.
  • Many export options: Reports can be exported to PDF, XLS, HTML, or CSV formats, and emailed to administrators.
  • Secure delegation: Delegate the task of report generation to technicians and IT staff securely, without giving them full access to the Office 365 Admin Center.
A holistic Office 365 administration solution