Solved

Exchange 2010 SP3 RU2 ActiveSync Powershell commands

Posted on 2014-10-10
2
134 Views
Last Modified: 2014-12-01
HI

does any one out there have a good power shell command or script that will give me the following information

1) Name
2) device name
3) device OS
4) device model
5) status of device

and so on


please let me know
0
Comment
Question by:SEHC
2 Comments
 
LVL 24

Expert Comment

by:Mohammed Khawaja
ID: 40373397
You could run the following script (credit goes to http://exchangeserverpro.com/forums/powershell-corner/17-get-list-all-activesync-users-info-exchange-2007-a.html):



$outObject = @()

$ActiveSyncMailboxes = Get-CasMailbox -Filter { HasActivesyncDevicePartnership -eq $true }

foreach ($CasMailbox in $ActiveSyncMailboxes) {

      $n = $CasMailbox.Name
      $dn = $CasMailbox.DisplayName
      $ma = $CasMailbox.PrimarySmtpAddress
      $id = $CasMailbox.Identity
      $exv = $CasMailbox.ExchangeVersion
      
      if ($exv -like "0.1 (8*") {
      
            $ActiveSyncDevices = Get-ActiveSyncDeviceStatistics -Mailbox $id
      
            foreach ($Device in $ActiveSyncDevices) {
                  $fst = $Device.FirstSyncTime
                  $lsat = $Device.LastSyncAttemptTime
                  $lss = $Device.LastSuccessSync
                  $dt = $Device.DeviceType
                  $did = $Device.DeviceID
                  $dua = $Device.DeviceUserAgent
                  $dm = $Device.DeviceModel
                  $dfn = $Device.DeviceFriendlyName
                  $dos = $Device.DeviceOS
                  $dosl = $Device.DeviceOSLanguage
                  $dpn = $Device.DevicePhoneNumber
            
                  $outObject += New-Object Object
                  $l = $outObject.length - 1
                  Add-Member -memberType NoteProperty -Name Name -Value $n -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DisplayName -Value $dn -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name PrimarySmtpAddress -Value $ma -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name Identity -Value $id -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name FirstSyncTime -Value $fst -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name LastSyncAttemptTime -Value $lsat -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name LastSuccessSync -Value $lss -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceType -Value $dt -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceID -Value $did -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceUserAgent -Value $dua -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceModel -Value $dm -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceFriendlyName -Value $dfn -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceOS -Value $dos -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DeviceOSLanguage -Value $dosl -inputObject $outObject[$l]
                  Add-Member -memberType NoteProperty -Name DevicePhoneNumber -Value $dpn -inputObject $outObject[$l]
      
            }
      
      #Variablen leeren
      $fst = $null
      $lsat = $null
      $lss = $null
      $dt = $null
      $did = $null
      $dua = $null
      $dm = $null
      $dfn = $null
      $dos = $null
      $dosl = $null
      $dpn = $null
      
      }
      
      $n = $null
      $dn = $null
      $ma = $null
      $id = $null
      $exv = $null


}

$outObject > activesyncdevices.txt
0
 
LVL 16

Accepted Solution

by:
Rajitha Chimmani earned 500 total points
ID: 40373400
Please try the script below. This script scans all active sync enabled users and provides the device status

$Arrayobj = @()
$ASEnabledMailboxes = Get-CASMailbox -ResultSize unlimited -Filter {(ActivesyncEnabled -eq $True)}
Foreach($User in $ASEnabledMailboxes){
[string]$Name = $User.Name
[string]$SMTPAddress = $User.PrimarySMTPAddress
$DeviceStats = Get-ActiveSyncDeviceStatistics -Mailbox $SMTPAddress
if($DeviceStats -ne $null){
foreach($Device in $DeviceStats){
$Obj = New-Object -TypeName system.Object
$Obj | Add-Member -MemberType noteproperty -Name Name -Value $Name
$Obj | Add-Member -MemberType noteproperty -Name DeviceID -Value $Device.DeviceID
$Obj | Add-Member -MemberType noteproperty -Name DeviceOS -Value $Device.DeviceOS
$Obj | Add-Member -MemberType noteproperty -Name DeviceModel -Value $Device.DeviceModel
$Obj | Add-Member -MemberType noteproperty -Name DeviceType -Value $Device.DeviceType
$Obj | Add-Member -MemberType noteproperty -Name DeviceStatus -Value $Device.Status
$Obj | Add-Member -MemberType noteproperty -Name LastSync -Value $Device.LastSuccessSync
$Arrayobj += $Obj
}
}
}
$Arrayobj | Export-csv users.csv -NoTypeInformation

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now