Skip to content

Commit 0e9b5e7

Browse files
authored
Create README.md
This script identifies shared mailboxes that have no assigned owners or members by analysing mailbox permissions in Exchange Online. It detects shared mailboxes where no user (other than system accounts) has FullAccess permissions, indicating the mailbox is effectively unmanaged.
1 parent 7ed7ae3 commit 0e9b5e7

File tree

1 file changed

+113
-0
lines changed
  • scripts/m365-get-shared-mailboxes-without-owners

1 file changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
2+
3+
# Get Shared Mailboxes Without Owners
4+
5+
## Summary
6+
7+
This script identifies **shared mailboxes that have no assigned owners or members** by analysing mailbox permissions in Exchange Online. It detects shared mailboxes where no user (other than system accounts) has **FullAccess** permissions, indicating the mailbox is effectively unmanaged.
8+
9+
The output can be used for **governance reviews, access audits, compliance reporting, and remediation planning** in large Microsoft 365 tenants.
10+
11+
## Why It Matters
12+
13+
In many organisations, shared mailboxes are created for teams, projects, or business functions. Over time, users leave, teams are restructured, or ownership is never formally assigned.
14+
15+
Unowned shared mailboxes can:
16+
- Contain sensitive or regulated data
17+
- Remain accessible to unintended users
18+
- Fail internal access control or audit requirements
19+
- Become unmanaged attack surfaces
20+
21+
This script enables administrators to **proactively identify and remediate orphaned shared mailboxes** before they become a security or compliance risk.
22+
23+
## Benefits
24+
- Improves mailbox ownership governance
25+
- Supports security and compliance audits
26+
- Reduces risk of unauthorised data access
27+
- Helps maintain least-privilege access
28+
- Scales efficiently for large Microsoft 365 tenants
29+
30+
31+
# [PnP PowerShell](#tab/pnpps)
32+
33+
```powershell
34+
35+
Connect-ExchangeOnline -ShowBanner:$false
36+
37+
$sharedMailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited
38+
$results = @()
39+
40+
foreach ($mailbox in $sharedMailboxes) {
41+
42+
$permissions = Get-MailboxPermission -Identity $mailbox.Identity |
43+
Where-Object {
44+
$_.AccessRights -contains "FullAccess" -and
45+
$_.IsInherited -eq $false -and
46+
$_.User -notlike "NT AUTHORITY\SELF"
47+
}
48+
49+
if ($permissions.Count -eq 0) {
50+
$results += [PSCustomObject]@{
51+
DisplayName = $mailbox.DisplayName
52+
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
53+
MailboxGuid = $mailbox.Guid
54+
}
55+
}
56+
}
57+
58+
$results
59+
60+
61+
```
62+
63+
64+
# [Usage](#tab/pnpps)
65+
66+
1. Connect to Exchange Online with sufficient permissions:
67+
- Exchange Administrator or Global Administrator
68+
2. Run the script
69+
3. Review the output in the console or pipe it to export formats, for example:
70+
71+
```powershell
72+
73+
$results | Export-Csv ".\SharedMailboxesWithoutOwners.csv" -NoTypeInformation
74+
75+
76+
```
77+
78+
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
79+
***
80+
81+
82+
## Output
83+
The script returns objects with the following properties:
84+
- **DisplayName**
85+
- **PrimarySmtpAddress**
86+
- **MailboxGuid**
87+
88+
Each row represents a shared mailbox with **no assigned owners or members**.
89+
90+
## Notes
91+
- The script evaluates **explicit FullAccess permissions only**
92+
- Mailboxes managed exclusively via groups will appear as owned only if group permissions are assigned directly
93+
- Designed for large tenants using server-side filtering and minimal object expansion
94+
- Can be safely scheduled or integrated into governance reporting workflows
95+
96+
## Contributors
97+
98+
| Author(s) |
99+
|-----------|
100+
| [Josiah Opiyo](https://github.com/ojopiyo) |
101+
102+
*Built with a focus on automation, governance, least privilege, and clean Microsoft 365 tenants—helping M365 admins gain visibility and reduce operational risk.*
103+
104+
105+
## Version history
106+
107+
Version|Date|Comments
108+
-------|----|--------
109+
1.0|Jan 11, 2026|Initial release
110+
111+
112+
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
113+

0 commit comments

Comments
 (0)