Skip to content

Commit b2b4c1c

Browse files
authored
Merge pull request #918 from ojopiyo/patch-13
Create README.md
2 parents 7935b14 + f7818ee commit b2b4c1c

File tree

4 files changed

+165
-0
lines changed

4 files changed

+165
-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+
# [Exchange](#tab/exc)
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+
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/m365-get-shared-mailboxes-without-owners" aria-hidden="true" />
328 KB
Loading
58.7 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[
2+
{
3+
"name": "m365-get-shared-mailboxes-without-owners",
4+
"source": "pnp",
5+
"title": "Get Shared Mailboxes Without Owners",
6+
"shortDescription": "This script identifies shared mailboxes that have no assigned owners or members by analysing mailbox permissions in Exchange Online.",
7+
"url": "https://pnp.github.io/script-samples/m365-get-shared-mailboxes-without-owners/README.html",
8+
"longDescription": [
9+
""
10+
],
11+
"creationDateTime": "2026-01-11",
12+
"updateDateTime": "2026-01-11",
13+
"products": [
14+
"Office"
15+
],
16+
"metadata": [
17+
{
18+
"key": "POWERSHELL",
19+
"value": "7.2.0"
20+
}
21+
],
22+
"categories": [
23+
"Report"
24+
],
25+
"tags": [
26+
"Connect-ExchangeOnline"
27+
],
28+
"thumbnails": [
29+
{
30+
"type": "image",
31+
"order": 100,
32+
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/m365-get-shared-mailboxes-without-owners/assets/preview.png",
33+
"alt": "Preview of the sample Get Shared Mailboxes Without Owners"
34+
}
35+
],
36+
"authors": [
37+
{
38+
"gitHubAccount": "ojopiyo",
39+
"company": "",
40+
"pictureUrl": "https://github.com/ojopiyo.png",
41+
"name": "Josiah Opiyo"
42+
}
43+
],
44+
"references": [
45+
{
46+
"name": "Want to learn more about Microsoft Graph PowerShell SDK and the cmdlets",
47+
"description": "Check out the Microsoft Graph PowerShell SDK documentation site to get started and for the reference to the cmdlets.",
48+
"url": "https://learn.microsoft.com/graph/powershell/get-started"
49+
}
50+
]
51+
}
52+
]

0 commit comments

Comments
 (0)