Master Exchange Online PowerShell: Get Mailbox Permissions Fast
Managing permissions in Exchange Online requires a precise understanding of how access controls are implemented and audited. The Exchange Online PowerShell module provides a direct interface to these configurations, allowing administrators to view and modify mailbox permissions with granular control. One of the most critical cmdlets for security management is the Get-MailboxPermission command, which reveals the explicit and inherited rights assigned to users and service accounts. This deep dive into mailbox access helps security teams identify potential vulnerabilities or misconfigurations that could lead to unauthorized data exposure.
Understanding Mailbox Permission Types
Before executing specific queries, it is essential to distinguish between the different layers of permissions within Exchange Online. There are two primary categories: Mailbox Permissions and Folder Permissions. Mailbox Permissions apply to the entire mailbox database object, governing overarching actions like full access or send-as rights. In contrast, Folder Permissions are tied to specific sub-folders such as Calendar, Tasks, or Inbox, controlling actions like read-only access or availability of items. The Get-MailboxPermission cmdlet specifically targets the former, providing a high-level view of who has direct access to the mailbox itself.
Basic Syntax and Common Parameters
The fundamental syntax for retrieving permissions is straightforward, relying on the identity of the target mailbox. The most common usage involves piping the results to Format-List to ensure readability of the returned objects. Below is the basic command structure used to query a single user.
Example: Querying a Single Mailbox
Get-MailboxPermission -Identity "j.smith@companydomain.com" | Format-List User, AccessRights, IsInherited, Deny
This command returns a list of users or groups that have explicit permissions on the mailbox for "j.smith." The output details the specific access level (such as FullAccess or SendAs), whether the permission is inherited from a parent container, and if the access is denied.
Interpreting the Results: User, AccessRights, and IsInherited
Understanding the columns in the output is vital for accurate auditing. The User column identifies the trustee, which is often a user account, a security group, or a legacy mailbox. The AccessRights column specifies the level of control, ranging from ReadPermission to Owner. The IsInherited boolean indicates if the permission was directly applied or propagated down from a parent scope, such as a "Domain Users" group. This distinction is crucial for cleaning up legacy or unwanted access rights.
Advanced Filtering and Managing Access
For large environments, filtering the results is necessary to isolate specific security risks. Administrators can utilize the -User parameter to check what permissions a specific account holds across multiple mailboxes, or use wildcard searches to audit entire departments. Furthermore, this cmdlet is the logical precursor to the Add-MailboxPermission and Remove-MailboxPermission cmdlets. When removing access, it is generally recommended to target the specific user rather than breaking inheritance for the entire group to maintain security integrity for other users.
Filtering for External Users
Get-MailboxPermission -Identity "Marketing Department" | Where-Object { $_.User -like "*\EXT*" }
Exchange Online assigns external sharing permissions with a specific identifier containing "EXT." This command helps administrators quickly identify which mailboxes have shared resources with partners or third-party organizations, ensuring compliance with data loss prevention policies.
Common Security Scenarios and Best Practices
Security audits often focus on two high-risk scenarios: privileged accounts and dormant mailboxes. Application impersonation roles used by third-party apps often require Full Access to mailboxes, but these assignments can become outdated. Similarly, departing employees' direct permissions must be revoked immediately to prevent data exfiltration. Using Get-Mailbox in conjunction with Get-MailboxPermission allows for the automated review of permissions for mailboxes that have not logged in for over 90 days, streamlining the offboarding process.
Troubleshooting and Performance Considerations
When running these commands across a hybrid environment, administrators might encounter throttling limits imposed by Exchange Online. To mitigate performance hits, it is advisable to run bulk queries during off-peak hours or utilize the -ResultSize parameter to limit the dataset. If the results return stale data, ensure that the Exchange Online PowerShell module is updated to the latest version. Occasionally, permissions assigned via Azure AD roles might not display as expected in the AccessRights list; in these instances, verifying the role assignments in the Azure portal is the next logical troubleshooting step.