powershellexchange-server-2010

How to get Members of GroupMailboxes in PowerShell Exchange


I'm trying to get the Members of my groupMailboxes. I already wrote a script for sharedMailboxes that works well. If I want to apply the same for groupMailboxes I get an error.

Get-Mailbox -GroupMailbox | Get-Mailboxpermission -GroupMailbox

The Error I get is that all the groupMailboxes aren't found as recipient.

This is how I did it for sharedMailboxes which works fine.

Get-Mailbox -Filter {recipienttypedetails -eq "SharedMailbox"} | Get-Mailboxpermission

This is another way I tried to implement it.

Get-Mailbox -GroupMailbox -Filter {recipienttypedetails -eq "GroupMailbox"} | Get-Mailboxpermission -GroupMailbox

Here I get the same error that the groupMailboxes can't be found as recipients. The error dosen't make sense to me, because I clearly get the GroupMailboxes from the Get-Mailbox command. How cant these Mailboxes be found for the Mailboxpermisson command then?


Solution

  • That should work: Get-EXORecipient -ResultSize unlimited | where RecipientTypeDetails -eq "GroupMailbox" | foreach { if (Get-AzureADGroupMember -ObjectId $.ExternalDirectoryObjectId | where DisplayName -Match "xyz") {Write-Host $.Name}}