Solved

Exchange 2010 SP3 RU2 ActiveSync Powershell commands

Posted on 2014-10-10
2
138 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 25

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
how to add IIS SMTP to handle application/Scanner relays into office 365.

860 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