I want to obtain a list of all shared mailboxes and expand the group membership.
I have the following
Get-EXOMailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Get-MailboxPermission | select *user | where { ($_.User -Notlike 'NT*' -and $_.User -Notlike '*@*') }
This returns all the group memberships. How do I pipe this into the following please?
Get-AzureADGroup -SearchString <variable> | Get-AzureADGroupMember | Select DisplayName, Mail
I have tried this:
$groupnames = (Get-EXOMailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Get-MailboxPermission | select *user | where { ($_.User -Notlike 'NT*' -and $_.User -Notlike '*@*') })
foreach($item in $groupnames){
$item
Get-AzureADGroup -SearchString $item | Get-AzureADGroupMember | Select DisplayName, Mail
}