Skip to content

Instantly share code, notes, and snippets.

@ThoZed
Created September 10, 2019 17:00
Show Gist options
  • Save ThoZed/e3c7d392ab42db42b463b44a1dcbe086 to your computer and use it in GitHub Desktop.
Save ThoZed/e3c7d392ab42db42b463b44a1dcbe086 to your computer and use it in GitHub Desktop.
msExchange_list_MobileDeviceStatistics
#
# PSSnapin Load
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
#
# Create list with MobileDeviceStatistics for each mailbox extend output with Mailbox and MailboxUser
#
$UserList = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_{*"} | Get-Mailbox
$UserList | foreach {
$User = $_
Get-MobileDeviceStatistics -Mailbox $_} | fl @{l='Mailbox';e={$User.SamAccountName}},@{l='MailboxUser';e={[regex]::Match($_.Identity,'^.+/(.+)/ExchangeActiveSyncDevices/.+').Captures.groups[1].value}},*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment