How to Get a List of Mailboxes a User Has Access to in Exchange/Microsoft 365 via PowerShell?

To get a list of mailboxes a user has access to in Exchange/Microsoft 365 via PowerShell, follow these steps:

  1. Open the PowerShell command prompt with administrator privileges.
  2. Connect to your Exchange/Microsoft 365 account using the following command: $credential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking This will prompt you for your Exchange/Microsoft 365 account credentials and establish a remote PowerShell session to your account.
  3. Once connected, run the following command to get a list of mailboxes the user has access to: Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User <UserName> | Where-Object {$_.AccessRights -like "*FullAccess*"} | Select-Object Identity Replace <UserName> with the name of the user you want to check access for.
  4. This will return a list of mailboxes that the user has full access to.

Note: You may need to adjust your Exchange/Microsoft 365 account permissions or PowerShell execution policy to perform this action.