Quantcast
Channel: Exchange Server 2013 - Mobility and ActiveSync forum
Viewing all articles
Browse latest Browse all 1206

ActiveSync PowerShell Script

$
0
0

I am trying to put a script together that will allow for me to run a report against ActiveSync devices my objective is to not only capture Device info but also to capture two properties from each users AD account (Get-ADUser -ID something -Properties EmployeeID, BusinessCategory 

I am by no means a PowerShell Wiz and what you see before you is what I have gathered from various places including some help from couple of guys at StackOverflow. It all seems to work if I tell it to gather information for one user ($AUser = Get-CASmailbox -ID SomeUser) but when I run the script as is seems like users identities get lost. Any insight or help will be appreciated.

$ASUser = Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -eq $True -and DisplayName -notlike "CAS_{*"}

$Devices = ForEach($User in $ASUser) {
    $ACT = Get-ADUser -ID $_.SAMAccountName -Properties EmployeeID, BusinessCategory
    Get-ActiveSyncDeviceStatistics -Mailbox $_.identity | ForEach{
        Add-Member -InputObject $_ -NotePropertyName 'EmployeeID' -NotePropertyValue $ACT.EmployeeID
        Add-Member -InputObject $_ -NotePropertyName 'BusinessCategory' -NotePropertyValue $ACT.BusinessCategory
        Add-Member -InputObject $_ -NotePropertyName 'Name' -NotePropertyValue $User.Name
        Add-Member -InputObject $_ -NotePropertyName 'Email' -NotePropertyValue $User.PrimarySMTPAddress -PassThru
    }
}

$Devices | Select Name,Email,EmployeeID,BusinessCategory,DeviceModel,DevicePhoneNumber,DeviceID,FirstSyncTime,LastSyncTime | Export-CSV "C:\Path\To\Export.CSV" -NoTypeInformation


Viewing all articles
Browse latest Browse all 1206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>