Today, I have some lines to drop about how to simply list all your shared mailboxes.
In this case I wanted to get all email addresses.
Step 1: Connect to your environment
Connect to you on-premises Exchange environment.
Step 2: Retrieve On-Premises Shared Mailboxes
Let's start by fetching all the remaining shared mailboxes from your on-premises environment. Open up your PowerShell console and execute the following:
Step 3: Retrieve the remote shared mailboxes
Run the following commands
Get all mailboxes
Step 5: Consolidate the Results
It's time to bring everything together and create a unified list of shared mailboxes. Run the following commands to consolidate the on-premises and Exchange Online results:
Step 1: Connect to your environment
Connect to you on-premises Exchange environment.
Step 2: Retrieve On-Premises Shared Mailboxes
Let's start by fetching all the remaining shared mailboxes from your on-premises environment. Open up your PowerShell console and execute the following:
$OnPremSharedMailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize unlimited | Select-Object PrimarySmtpAddress
Step 3: Retrieve the remote shared mailboxes
Run the following commands
Get all mailboxes
$RemoteMailboxes = Get-RemoteMailbox -ResultSize unlimited
Get all remotesharedmailboxes and filter only the smtpaddress
$RemoteMailboxes | Where-Object { $_.RecipientTypeDetails -eq "RemoteSharedMailbox" } | select PrimarySmtpAddress
It's time to bring everything together and create a unified list of shared mailboxes. Run the following commands to consolidate the on-premises and Exchange Online results:
$AllSharedMailboxes = $OnPremSharedMailboxes + $ExchangeOnlineSharedMailboxes
With this command, you'll combine the arrays of on-premises and Exchange Online shared mailbox addresses into a single array called '$AllSharedMailboxes'. You can make other choices in your filter to generate a different list.
Step 6: Display the Results
And just like that, your PowerShell console will present you with a complete list of shared mailbox addresses, combining the best of both on-premises en Exchange Online.
Step 6: Display the Results
$AllSharedMailboxes
And just like that, your PowerShell console will present you with a complete list of shared mailbox addresses, combining the best of both on-premises en Exchange Online.
No comments:
Post a Comment