Skip to content

Instantly share code, notes, and snippets.

@danjpadgett
Created May 6, 2016 14:16
Show Gist options
  • Save danjpadgett/8ae39664e395bdb95e3395899d5cca8c to your computer and use it in GitHub Desktop.
Save danjpadgett/8ae39664e395bdb95e3395899d5cca8c to your computer and use it in GitHub Desktop.
<#
.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment