Powershell Script to list Office 365 Shared Mailboxes

Updated 1 year ago by admin

Run the following Powershell script to connect to Office 365 and export a list of Shared Mailboxes:

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Get-Recipient -RecipientTypeDetails SharedMailbox > SharedMailboxes.txt
Remove-PSSession $Session

The script will create a file called Sharedmailboxes.txt which contains a list of Shared Mailboxes.

How did we do?