Grant Read-Only Access to SharePoint Online Subsites with PowerShell
Question details
Grant a user read-only access across a SharePoint Online site collection and its subsites, including subsites with unique permissions.

- Product
- SharePoint Online
- Device & OS
- not provided
- Scenario
- An administrator wants to use PowerShell to give a user read access throughout a site collection.
- Observed behavior
- Permissions granted at the site collection root do not automatically apply to subsites that have broken permission inheritance.
Use an account that can manage permissions and see every target subsite, and confirm that the user already exists in the tenant. Install PnP PowerShell in a supported PowerShell version and have an Entra ID app registration configured for interactive sign-in with the required delegated permissions and consent.
Add the user to Visitors groups with PnP PowerShell
Use this approach to add the user at the site collection root and at subsites with unique site permissions.
Subsites that inherit permissions receive access from their parent. A subsite with unique site permissions must be handled separately.
This approach assumes each target site's associated Visitors group provides the intended read-only access. Review the groups and their permission levels before adding the user.
In PowerShell, install the module with Install-Module PnP.PowerShell -Scope CurrentUser if needed. Set the values for your environment, then connect: $site = 'https://contoso.sharepoint.com/sites/example'; $clientId = 'YOUR-APP-CLIENT-ID'; $user = 'user@contoso.com'; Connect-PnPOnline -Url $site -ClientId $clientId -Interactive.
Run: $root = Get-PnPWeb; $targets = @($root.Url); foreach ($web in @(Get-PnPSubWeb -Recurse)) { Get-PnPProperty -ClientObject $web -Property HasUniqueRoleAssignments | Out-Null; if ($web.HasUniqueRoleAssignments) { $targets += $web.Url } }; $targets. Review the resulting URLs before continuing.
For each URL in the target list, open the site and go to Settings > Site permissions > Advanced permissions settings. Check that its associated Visitors group exists and has the intended Read permission; resolve any exceptions before running the next step.
Run: foreach ($url in $targets) { Connect-PnPOnline -Url $url -ClientId $clientId -Interactive; $group = Get-PnPGroup -AssociatedVisitorGroup; if ($group) { Add-PnPGroupMember -Group $group -LoginName $user; Write-Host "Added at $url" } else { Write-Warning "No associated Visitors group at $url" } }. Complete interactive sign-in when prompted and review any errors or warnings.
On representative sites, open Settings > Site permissions > Advanced permissions settings and use Check Permissions for the user. Also test access to representative lists and files, especially where permissions have been customized.
Work with SharePoint documents using WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for working with compatible documents. It can help users move between Office files with minimal disruption, but SharePoint permissions must still be managed in Microsoft 365.

Frequently Asked Questions
Will granting access at the site collection root cover every subsite?
It covers subsites that inherit permissions from the root. Subsites with unique permissions need their own access assignment or an assignment inherited from their nearest permitted parent.
Does the Visitors group always grant read-only access?
Not necessarily. In each target site, open Settings > Site permissions > Advanced permissions settings and verify the group's assigned permission level before adding the user.
Can a user still edit after being added to a Visitors group?
Yes. A separate direct permission or group membership may grant higher access. Use Check Permissions in the site's advanced permissions settings to investigate the user's effective access.
Does this script cover lists and files with unique permissions?
No. The script targets site-level permissions. Lists, libraries, folders, and files that have broken inheritance must be reviewed and handled separately.
Why might the script miss a subsite?
The account running Get-PnPSubWeb must be able to discover the subsite. Check the account's access and compare the output with your site's inventory before applying permissions.




