/
/

How to Get ActiveSync Device Details with PowerShell at Scale

by Miguelito Balba, IT Editorial Expert
How to Get ActiveSync Device Details with PowerShell at Scale blog banner image

Instant Summary

This NinjaOne blog post offers a comprehensive basic CMD commands list and deep dive into Windows commands with over 70 essential cmd commands for both beginners and advanced users. It explains practical command prompt commands for file management, directory navigation, network troubleshooting, disk operations, and automation with real examples to improve productivity. Whether you’re learning foundational cmd commands or mastering advanced Windows CLI tools, this guide helps you use the Command Prompt more effectively.

Key Points

  • Unmanaged clients connecting to an organization’s ActiveSync environment may pose risks and create security blind spots.
  • Mitigate potential risks by creating a framework that manages and maintains device data to assess compliance, and which should be updated, quarantined, or decommissioned.
  • Steps for Getting ActiveSync Device Details and Maintaining This Documentation:
    • Inventory of all ActiveSync devices
    • Enrichment with usage and sync data
    • Identification of legacy or noncompliant devices
    • Normalization, logging, and exporting data
    • Automation and safe operation of ActiveSync device management
    • Driving follow-up actions
  • NinjaOne Support for Building ActiveSync Device Data: Job deployment and scheduling, credential management, export & log attachment, ticket automation, and dashboard cards
  • Maintain accurate ActiveSync device data to ensure devices connecting to ActiveSync environments meet defined access and policy requirements within your security framework.

Microsoft ActiveSync is an essential tool in bridging the gap between Microsoft Exchange and mobile devices. But with sophisticated threats looming in the background, maintaining a secure connection between Microsoft Exchange and mobile devices is crucial. One way to build protection is to ensure all clients are trustworthy by creating a framework that continuously audits ActiveSync partnerships.

In this guide, we will walk you through utilizing Microsoft’s Get-ActiveSyncDevice and related cmdlets in doing regular audits by providing accurate, granular device data, combining it with modern reporting practices. This workflow supports access hygiene, policy enforcement, and client deprecation.

At a glance

TaskPurpose and value
Task 1: Enumerate all ActiveSync devicesThis task produces a dataset that is the foundation for enforcement actions, staleness checks, and client deprecation reviews.
Task 2: Enrich with usage and sync dataThis task transforms raw device entries into actionable items for lifecycle and compliance decisions.
Task 3: Identify legacy or noncompliant devicesThis prioritizes remediation actions such as user re-enrollment, device removal, or client upgrades.
Task 4: Normalize, log, and exportThis allows auditors, security teams, and MSP clients to compare runs across time and validate reductions in risky devices.
Task 5: Automate and operate safelyThis task ensures you always have access to fresh device data without operational overhead.
Task 6: Drive follow-up actionsThis closes the loop between reporting, compliance, and risk reduction.

Prerequisites:

Before proceeding with the tasks, you need to consider the following factors first:

  • Exchange Online PowerShell module and roles to query mobile devices
  • Secure credential or app-only authentication for unattended runs
  • Central path for CSV, JSON, and run logs
  • Defined policy matrix for allowed, quarantined, and blocked device states

Task 1: Enumerate all ActiveSync devices

To begin, you need to inventory all devices using ActiveSync by running the Get-ActiveSyncDevice cmdlet. Get-ActiveSyncDevice shows direct relationships between devices and mailboxes. Here’s what you should do to get an authoritative dataset for all downstream analysis:

  1. Connect to Exchange Online using PowerShell.
  2. Retrieve the complete device list by running the complete inventory command:

Get-ActiveSyncDevice -ResultSize Unlimited |

Select-Object Identity, UserDisplayName, DeviceType, DeviceModel, DeviceOS, DeviceAccessState, DeviceAccessStateReason, ClientVersion, WhenChanged

  1. Record totals and add TenantId, AsOf timestamp, and script version to all records.
  2. This cmdlet provides a direct association between devices and mailboxes, serving as the baseline for subsequent analysis.

Task 2: Enrich with usage and sync data

For this task, you will use the Get-MobileDeviceStatistics cmdlet to retrieve synchronization and policy status details for mobile devices associated with a specific mailbox, enriching each record with deeper context, capturing more detailed activity, staleness, or policy freshness.

Here are the steps:

  1. Connect to Exchange Online PowerShell.
  2. Loop through each mailbox or device by running this command:

Get-MobileDeviceStatistics -Mailbox <user> |

Select-Object DeviceFriendlyName, LastSuccessSync, LastPolicyUpdateTime, ClientInformation

  1. Join results with your baseline inventory (Task 1) using DeviceId and UserPrincipalName.
  2. Compute the following data points:
    • Device age
    • Last sync window
    • Staleness category (30/60/90+ days)

Task 3: Identify legacy or noncompliant devices

For this step, you will evaluate each device to determine if it still meets compliance requirements. Here are the actions to take:

  • Flag devices if:
    • They are using outdated OS versions
    • They are using old ClientVersion strings
  • Mark devices still using Basic or legacy authentication (cross-reference your “disable legacy authentication” baseline).
  • Identify inactive devices or those in a permanent quarantine or blocked state.
  • Prioritize cleanup or user re-enrollment based on policy.

Task 4: Normalize, log, and export

Your next actions focus on maintaining a consistent audit by normalizing every output field, applying consistent naming conventions, and exporting in multiple formats.

Here’s how:

  1. Standardize all fields:
    • DeviceOSVersion
    • LastSuccessSync
    • State
    • ActionRequired
  1. Export results:
    • CSV for operational reviews
    • JSON for dashboards or log ingestion tools
  1. Write a run log summarizing the following:
    • Parameters
    • Record counts
    • Duration
  1. Retain at least 12 months of results for pattern analysis.

Task 5: Automate and operate safely

This task applies to enterprise-grade, multi-tenant MSP operations, as manual audits are not advised for large-scale environments. Here’s how to create an automation framework for ActiveSync device management:

  1. Authenticate app-only and page large result sets to avoid throttling.
  2. Add retry logic for transient errors and maintain idempotent outputs.
  3. Schedule weekly inventory runs and monthly deltas for growth tracking.
  4. Integrate with compliance or alert workflows for legacy and stale devices.

Task 6: Drive follow-up actions

To complete the framework, you need to enforce governance by strengthening both security and operational workflows. Here are the actions you need to take:

  • User communication: Send notice and setup information to users whose devices require an upgrade or re-enrollment.
  • Remediation: Remove stale partnerships or apply an automated quarantine policy with approvals.
  • Security validation: Align findings with Conditional Access and Exchange Online backup verifications.
  • Governance: Link metrics to password spray prevention and shared mailbox restrictions.

Best practices summary table

PracticePurposeValue delivered
Combine Get-ActiveSyncDevice and Get-MobileDeviceStatisticsFull contextDevice, OS, and activity coverage
Flag inactive and legacy clientsRisk reductionFewer attack paths and sync issues
Normalize and exportAuditabilityEasy diffs and compliance reporting
App-based authSecuritySafe automation at scale
Trend analysisContinuous improvementVerifiable reduction in risky devices

Automation touchpoint example

You can use automation to streamline the creation, management, and maintenance of ActiveSync device data. Here are examples:

  • A scheduled job loops through mailboxes
  • The collection of device data via Get-ActiveSyncDevice and Get-MobileDeviceStatistics
  • Consolidating and normalizing results
  • Computing risk categories and writing CSV, JSON, and a log file
  • Emailing a digest listing legacy clients, stale devices, and quarantine candidates

NinjaOne integration

NinjaOne showcases tools and functionalities that can streamline employee data theft prevention.

NinjaOne serviceWhat it isHow it helps with employee data theft prevention
Job deployment and schedulingSchedule and run PowerShell jobsAutomates the collection of device data across mailboxes
Credential managementSecurely store credentialsEnsures safe access to mailboxes for device data retrieval
Ticket creationEnable ticket creation workflows for flagged devicesSupports scripted or report-driven ticket creation for stale, legacy, or quarantined devices
Dashboard cardsVisual cards in the NinjaOne dashboardShows device counts, sync freshness derived from scripted ActiveSync audits, and reductions in risky endpoints per tenant

Managing and maintaining ActiveSync device data

Having a well-kept ActiveSync device data documentation helps MSPs and IT teams to determine which devices need to be retired for an accurate device inventory. This also aids in maintaining Exchange Online hygiene for a safer and dependable security posture.

Key Takeaways

  • Use Get-ActiveSyncDevice and Get-MobileDeviceStatistics for a complete device view.
  • Identify legacy clients, outdated OS builds, and stale partnerships for remediation.
  • Normalize and export with timestamps and tenant IDs for repeatable audits.
  • Automate with app-based authentication and error handling.
  • Tie results into security posture improvements and compliance dashboards.

Utilize Microsoft’s Get-ActiveSyncDevice cmdlet and follow other best practices to ensure a compliant ActiveSync device inventory.

Related topics:

FAQs

Get-ActiveSyncDevice provides a baseline inventory of all devices connected to mailboxes via ActiveSync, showing device type, OS, and access state. Get-MobileDeviceStatistics enriches this inventory with usage, sync activity, and policy application status details, providing IT teams with a comprehensive view for audits and remediation actions.

You can automate the detection of stale devices by combining Get-ActiveSyncDevice with Get-MobileDeviceStatistics, evaluating last sync times, OS versions, and client versions. Categorize devices based on staleness thresholds (e.g., 30/60/90+ days) and integrate results with access governance or ticketing workflows for remediation.

Yes. In Exchange Online, you can automate ActiveSync device audits without storing user passwords by using app-only authentication with certificate-based access and Exchange RBAC for applications, where supported. This enables unattended PowerShell execution to collect ActiveSync device and synchronization data. When combined with secure automation and credential management tools such as NinjaOne, scripts can be scheduled, results logged, and audit data retained without relying on interactive user credentials.

For auditability and reporting, export normalized device data to CSV for operational review, JSON for dashboards, and ingestion into monitoring tools, and maintain detailed run logs. Including timestamps and TenantId ensures historical comparisons and trend analysis.

You can complement ActiveSync audit information with RMM features like NinjaOne’s, including patching, encryption, app control, and device configuration baselines, to improve security posture and ensure compliance.

You might also like

Ready to simplify the hardest parts of IT?