Finding a complete list of mobile devices in Office 365 that have not synced in X days can be a bit of a task through the online portal. This script will connect to your Office 365 environment and export all those mobiles that have not syncronised in the last 14 days.

The Cmdlet in this script are for tenants that have been upgraded to Wave 15. If you are still running Wave 14, then replace Get-MobileDeviceStatistics with Get-ActiveSyncDeviceStatistics



        Script will output a full list of mobile devices that have not 
        synced in 14 days 
        PS> InactiveMobiles.ps1 
        For Wave 14 Customers change the Get-MobileDeviceStatistics to Get-ActiveSyncDeviceStatistics 
        Dan Rose 
function ConnectTo-ExchangeOnline  
            Connects to Exchange Online with tenant credentials 
            Tenant Username/Password 
    # Get Credentials  
    $Office365Credentials = Get-Credential 
    # Create remote Powershell session  
    $Script:Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Office365credentials -Authentication Basic –AllowRedirection          
    # Import the session  
    Import-PSSession $Session -AllowClobber | Out-Null  
# Gather Mailboxes 
$users = Get-Mailbox -ResultSize Unlimited  
foreach ($user in $users) { 
    # Get mobiles that have not synced for the last x days 
    $mobiles = Get-MobileDeviceStatistics -Mailbox $user.identity | 
        where {$_.LastSuccessSync -lt (Get-Date).AddDays(-14)} | 
        select DeviceModel,LastSuccessSync 
    foreach ($mobile in $mobiles) { 
        $ObjProperties = New-Object PSObject 
        Add-Member -InputObject $ObjProperties -MemberType NoteProperty -Name "UserPrincipalName" -Value $user.userprincipalname 
        Add-Member -InputObject $ObjProperties -MemberType NoteProperty -Name "DeviceModel" -Value $mobile.DeviceModel 
        Add-Member -InputObject $ObjProperties -MemberType NoteProperty -Name "LastSuccessSync" -Value $mobile.LastSuccessSync 
        # Output to file 
        $MobileString = "$($user.userprincipalname),$($mobile.DeviceModel),$($mobile.LastSuccessSync)" 
        Out-File -FilePath "c:\inactivemobiles.csv" -InputObject $MobileString  -Encoding UTF8 -append 
Remove-PSSession $Script:Session