Skip to content

Instantly share code, notes, and snippets.

@chadmando
Last active April 11, 2022 13:01
Show Gist options
  • Save chadmando/308575e6c3f525ff08657f60085c95d2 to your computer and use it in GitHub Desktop.
Save chadmando/308575e6c3f525ff08657f60085c95d2 to your computer and use it in GitHub Desktop.
Show mobile devices associated with each mailbox in Exchange Online
# collect mailboxes that are not shared or resources
$users = Get-Mailbox |
Where-Object {$_.IsShared -eq $False -and $_.IsResource -eq $False} |
Select-Object -ExpandProperty UserPrincipalName
foreach ($user in $users){
Write-Host $user -ForegroundColor green
Get-MobileDevice -Mailbox $user |
Select-Object -Property FriendlyName,DeviceUserAgent,DeviceAccessState, DeviceModel, Identity |
Format-Table -AutoSize
}
# alternative one-liner; requires EXO V2
Get-EXOMailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited |
Select-Object -ExpandProperty UserPrincipalName |
ForEach-Object -Process {Get-MobileDevice -Mailbox $_ } |
Select-Object -Property FriendlyName,DeviceUserAgent,DeviceAccessState, DeviceModel, Identity |
Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment