Exchange: List all ActiveSync Users & PhoneNumbers

Here is a script that will list you all Exchange users with a specific ActiveSync policy, it will link the users to their AD objects and list their Mobile Number if present.

Hopefully this helps someone..

 

<#
.NOTES
===========================================================================
Created on: 06/05/2016 14:41
Created by: dpadgett
Organization: dpadgett
Filename: Get-ActiveSyncUsers.ps1
===========================================================================
.DESCRIPTION
This will list all users with an activeSYNC policy of BYOD then output their
usernames, displaynames and mobile numbers from AD.
.USAGE
Change line 17 (to your exchange server)
Change line 23 to include your policy name
#>
$Session = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri http://server/PowerShell/
Import-PSSession $Session
Import-Module ActiveDirectory
$Output = @()
$list = Get-CASMailbox | where{ $_.activesyncmailboxpolicy -match "BYOD" } | select samaccountname, displayname
$List | % {
$output += [PSCustomObject] @{
FullName = $_.samaccountname
Username = $_.displayname
Phone = (Get-ADUser $_.samaccountname prop mobilephone).mobilephone
}
}
$Output

 

Cheers,

Dan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s