How to Export SharePoint Online Permissions for an Audit
Export SharePoint permissions with Microsoft's reports or a tested PowerShell script, see what each export leaves out, and save a dated baseline you can compare later.

You can export SharePoint permission information using Microsoft's reports or PowerShell. The right method depends on whether you need site-level access, selected users, or permissions on individual files. Save the result with its collection date if you expect to compare it later.
No single command exports all of it. An export can also look finished without answering the question: on a Microsoft 365 group site in our test tenant, a permissions export gave us 7 rows and not one named person. This guide shows which export fits which request, and how to tell when a file is incomplete.
Start with what the auditor is asking
Ask what they need before you run anything. These four requests need different exports.
| The auditor asks | Start with | What you get |
|---|---|---|
| Which sites are widely shared? | Site permissions across your organization | Counts for each site, not a list of people |
| What can this person reach? | Site permissions for users | The sites a chosen person can reach, with counts of items |
| Who can reach this site or library? | The PowerShell export below | Named people and groups at site and library level |
| What is shared inside this site, and with whom? | The site sharing report | File and folder sharing records, including direct access and sharing links. Group members may not be named |
Also ask whether they mean current access or an earlier date. An export captures what its source reports during collection, and some Microsoft reports can contain information up to 48 hours old. For a past date, see How to Audit Historical SharePoint Permissions.
Microsoft's reports
Site permissions across your organization
This SharePoint Advanced Management report downloads as a CSV with one row per site. It counts users, guests, Entra groups, sharing links and items with unique permissions. Use it to decide which sites to look at. It does not list who has access.
The first report can take up to 5 days. Later ones finish within 24 hours, and you can rerun it every 30 days. Microsoft says the data can be up to 48 hours older than the report, and that sites with a NoAccess lock and archived sites are left out.
Site permissions for users
This report lists the sites a chosen person can reach. It shows whether they have the whole site or only some content, with counts of items they reach directly and through groups. The CSV gives counts, not the names of those items.
You can keep up to five of these reports and rerun them every 30 days. The organization report has to have run at least once first.
Both reports need SharePoint Advanced Management. That comes from having at least one Microsoft Copilot license assigned, from the Plan 1 add-on, or from Microsoft 365 E7, on top of a qualifying subscription.
The site sharing report
This is the one to use for individual files and folders. A site admin runs it from the site itself:
- Open the site, then select Settings and Site usage.
- In the Shared with external users section, select Run report.
- Choose where to save the file, then select Save.
Despite that section's name, Microsoft describes the result as a CSV of every unique file, user, permission and link on the site. You get an email when it is ready.
The file is saved on the site you are reporting on, so choose a folder that site members cannot open. It also has limits:
- SharePoint groups appear by name, without the people inside them.
- Anyone links are not included.
- Links emailed directly but never clicked are not included.
- It covers one site at a time.
Export one site with PowerShell
Use this when you need named people and groups at site and library level, or when you don't have SharePoint Advanced Management.
You need:
- PowerShell 7.4 or later and the PnP PowerShell module:
Install-Module PnP.PowerShell -Scope CurrentUser - Your own Entra app registration, which PnP PowerShell has required since September 9, 2024
- An account that is a site admin of the site
- To run the separate Microsoft 365 and Entra group commands later in this guide, an app registration with the necessary Microsoft Graph read permissions. These may need administrator approval
Save this as Export-SitePermissions.ps1. It only reads, and it changes nothing in SharePoint.
param(
[Parameter(Mandatory)][string]$SiteUrl,
[Parameter(Mandatory)][string]$ClientId,
[string]$OutFile = ".\sharepoint-permissions-$((Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH-mm-ssZ')).csv"
)
$ErrorActionPreference = "Stop"
Connect-PnPOnline -Url $SiteUrl -Interactive -ClientId $ClientId
$collectedUtc = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
function New-Row($scope, $path, $member, $permission) {
[pscustomobject]@{
CollectedUtc = $collectedUtc
Site = $SiteUrl
Scope = $scope
Path = $path
Principal = $member.Title
LoginName = $member.LoginName
PrincipalType = $member.PrincipalType
Permission = $permission
}
}
function Read-Assignments($securable, $scope, $path) {
foreach ($assignment in $securable.RoleAssignments) {
Get-PnPProperty -ClientObject $assignment -Property Member, RoleDefinitionBindings | Out-Null
$levels = ($assignment.RoleDefinitionBindings | ForEach-Object Name) -join "; "
New-Row $scope $path $assignment.Member $levels
}
}
$web = Get-PnPWeb -Includes RoleAssignments
$rows = @(
Get-PnPSiteCollectionAdmin | ForEach-Object {
New-Row "Site admin" $web.ServerRelativeUrl $_ "Site collection administrator"
}
Read-Assignments $web "Site" $web.ServerRelativeUrl
Get-PnPList -Includes HasUniqueRoleAssignments, RoleAssignments, RootFolder |
Where-Object { -not $_.Hidden -and $_.HasUniqueRoleAssignments } |
ForEach-Object { Read-Assignments $_ "List or library" $_.RootFolder.ServerRelativeUrl }
Get-PnPGroup | ForEach-Object {
$group = $_
Get-PnPGroupMember -Group $group.Title | ForEach-Object {
New-Row "SharePoint group" $group.Title $_ "Member of the group"
}
}
)
# Finish reading before writing. Publish the CSV only after it is fully written.
if ($rows.Count -eq 0) {
throw "No permission rows were returned. No export was saved."
}
if (Test-Path -LiteralPath $OutFile) {
throw "The output file already exists: $OutFile"
}
$tempFile = "$OutFile.tmp"
if (Test-Path -LiteralPath $tempFile) {
throw "A temporary output file already exists: $tempFile"
}
try {
$rows | Export-Csv -LiteralPath $tempFile -NoTypeInformation -Encoding utf8
Move-Item -LiteralPath $tempFile -Destination $OutFile -ErrorAction Stop
}
finally {
if (Test-Path -LiteralPath $tempFile) {
Remove-Item -LiteralPath $tempFile
}
}
"Saved $($rows.Count) rows to $OutFile"
Then run it:
.\Export-SitePermissions.ps1 -SiteUrl "https://contoso.sharepoint.com/sites/Finance" -ClientId "<your app's client ID>"
We ran this on November 5, 2026, with PnP.PowerShell 3.4.1 on PowerShell 7.6, against three small test sites with fictional users: a team site, a Microsoft 365 group site and a site using nested Entra groups. It stopped with an error on a site that did not exist and left no file, and it refused to overwrite an existing export. We have not run it on a large site, so try a small one first.
It covers site admins, site-level permissions, lists and libraries with their own permissions, and the members of SharePoint groups. The collection time is recorded when the script starts. Permissions can change while it runs, so the result is not an exact snapshot of one instant. It does not cover subsites, hidden lists, individual files and folders, or the people inside Microsoft 365 and Entra groups.
What we found in the test exports
A group site can have no names at all
On our Microsoft 365 group site, the file had 7 rows: three SharePoint groups, the System Account, and the Microsoft 365 group's owners and members, listed as groups. Those people exist only in the Microsoft 365 group, so an auditor reading that file would not learn who has access.
The LoginName column can help identify whether a row represents a person or a group. These are the formats we saw in our test tenant:
i:0#.f|membership|is a user.c:0o.c|federateddirectoryclaimprovider|is a Microsoft 365 group. An_oat the end means its owners.c:0t.c|tenant|is an Entra security group.c:0-.f|rolemanager|was "Everyone except external users".
For the Microsoft 365 and Entra group entries shown above, the value after the last | contains the group's ID. To list the people, use it while still connected, and save the result with the same date:
Get-PnPMicrosoft365GroupMember -Identity "<group ID>" # members of a Microsoft 365 group
Get-PnPMicrosoft365GroupOwner -Identity "<group ID>" # its owners
Get-PnPEntraIDGroupMember -Identity "<group ID>" # members of an Entra security group
For an ID with _o at the end, leave that part off. In our test, a group nested inside an Entra group came back as an entry with no user name, so repeat the command for that group.
"Everyone except external users" looks like any other group
In our export it sat inside the Visitors group with the type SecurityGroup, one row among many. On our test site, that row represented Read permission for the special group covering internal users. One row like this can represent access for a large part of an organization. Search your export for it early in the review.
Limited Access is a pointer, not access to the site
Several people appeared on our test site with only Limited Access. Microsoft says SharePoint adds this level automatically when someone gets access to one specific item, and that it gives no extra permissions. Don't report those people as having access to the site. Treat the row as a sign that they can reach something inside it, then check the site sharing report.
You will also see groups named Limited Access System Group and SharingLinks. In our test these were created by SharePoint: the second kind stands for a sharing link.
Site admins can be missing from the permission rows
One site admin on our test site appeared nowhere else in the export. If you only read the permission rows, you can miss the people with the most access. That is why the script reads site admins separately.
What the file should contain
An export is only useful later if someone can tell what it was. Each row should show:
- The date and time of collection, in UTC
- The site, and where on the site the permission applies
- The person or group's name and login identifier. Where possible, also record its stable directory ID, because names and login identifiers can change. The sample script does not collect a stable ID for every account
- Whether it is a user or which kind of group
- The permission level
Keep a short note beside the file saying who ran it, which tool and version they used, and any sites that failed or were skipped. Store the original unchanged, and limit who can open it, because it shows who can reach sensitive content.
Compare two exports
Once you have two files, this shows what differs. It compares login identifiers rather than display names, so a renamed account can appear as a removal and an addition.
$before = Import-Csv ".\sharepoint-permissions-2026-08-01T09-00-00Z.csv"
$after = Import-Csv ".\sharepoint-permissions-2026-11-01T09-00-00Z.csv"
Compare-Object $before $after -Property Site, Scope, Path, LoginName, Permission |
Select-Object @{ n = "Change"; e = { if ($_.SideIndicator -eq "=>") { "Added" } else { "Removed" } } },
Site, Scope, Path, LoginName, Permission
A changed permission shows as two rows: one Removed and one Added. This tells you what is different between two dates. It does not show every change in between, or who made them. For that, see How to Investigate Who Changed SharePoint Permissions.
What an export does not prove
Be clear about these when you hand a file over:
- It does not show who opened anything. Having permission and using it are different questions. Purview audit logs record activity.
- A missing row does not prove someone has no access. They may be inside a group that was not expanded, or reach the content through a link the export leaves out.
- It describes one moment. Permissions and group memberships can change an hour later.
- It says nothing about earlier dates. Your record starts at your first export.
When Microsoft's tools are enough
For a one-time review of current access, the reports and the script above may be all you need. Follow the same steps each time and keep the files.
They get harder to rely on when people keep asking about earlier dates. Answering those needs regular exports from before the question came up, plus group memberships and audit records from the same period. You can build that yourself with scheduled exports, provided someone checks that each run succeeded. The sample script above requires interactive sign-in and is not ready to run unattended. Scheduled collection needs a separate authentication setup and testing.
FAQ
- Is there one command that exports all SharePoint permissions?
- No. Site permissions, group members, sharing links and file-level permissions come from different places. The exports in this guide each cover part of it, so say which ones you used.
- Can I export permissions without SharePoint Advanced Management?
- Yes. The site sharing report and PowerShell export above do not rely on the SharePoint Advanced Management reports. They work one site at a time, so a whole organization takes more effort.
- Does the site sharing report show who opened a file?
- No. It lists permissions and sharing links. To see who opened a file, search the Purview audit log, which keeps records for a limited time.
- How often should I export?
- Microsoft recommends running its snapshot reports quarterly. For your own records on sites that matter, weekly is a reasonable starting point, because the shorter the gap, the fewer changes lie between two exports.
Related reading
Related guides
All guides
Compliance & Audit10 min readintermediate
How to Investigate Who Changed SharePoint Permissions
Learn how to investigate a SharePoint permission change. Check when it happened, who made it when Microsoft 365 recorded their name, and what access looked like before and after.

Historical Access12 min readadvanced
How to Audit Historical SharePoint Permissions
SharePoint shows current permissions. Learn what Microsoft's audit log and snapshot reports can tell you about a past date, how to save permission records with PowerShell and how to explain when information is missing.

Microsoft 365 Security9 min readbeginner
How Long Does Microsoft 365 Keep SharePoint Audit History?
Learn how long Microsoft 365 keeps audit records with Audit (Standard) and Audit (Premium). See what the 10-year add-on covers, why some changes appear late and why audit records do not give you a full history of permissions.