Last active
April 11, 2022 13:01
-
-
Save chadmando/308575e6c3f525ff08657f60085c95d2 to your computer and use it in GitHub Desktop.
Show mobile devices associated with each mailbox in Exchange Online
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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