Permission & Access Issues

Grant a Security Group SharePoint Online Library Permissions with PowerShell

Nimra MalikNimra Malik Nov 25, 2026 869 views

Question details

Grant an Active Directory security group a custom permission level on a SharePoint Online library using PowerShell.

Grant a Security Group SharePoint Online Library Permissions with PowerShell
Product
SharePoint Online
Device & OS
not provided
Scenario
An administrator wants to manage library access through an Active Directory security group.
Observed behavior
The SharePoint Online Management Shell cannot directly resolve the security group in every scenario.
Before you start

Confirm that the AD security group is synchronized to Microsoft Entra ID, and obtain its Entra object ID. You also need permission to manage the library, an existing SharePoint group and custom permission level, and an app registration configured for PnP PowerShell authentication.

Solution 1Recommended

Assign library access through a SharePoint group with PnP PowerShell

Use this approach when the security group cannot be resolved directly by the SharePoint Online Management Shell.

The commands add the Entra security group to an existing SharePoint group, then grant that SharePoint group a custom permission level on the library.

Copying inherited permissions preserves existing access when inheritance is broken. Review those assignments afterward if the library should have more restrictive access.

1
Connect to the site

In PowerShell 7, install PnP PowerShell if needed with Install-Module PnP.PowerShell, then connect using Connect-PnPOnline -Url 'https://contoso.sharepoint.com/sites/SiteName' -Interactive -ClientId '<app-client-id>'. Replace the site URL and client ID with your values.

2
Add the security group

Run Add-PnPGroupMember -Identity 'Library Access' -LoginName 'c:0t.c|tenant|<group-object-id>'. Replace Library Access with the existing SharePoint group name and <group-object-id> with the synchronized security group's Microsoft Entra object ID.

3
Break library inheritance

Run Set-PnPList -Identity 'Documents' -BreakRoleInheritance -CopyRoleAssignments, replacing Documents with the library name. Skip this step if the library already has unique permissions.

4
Assign the custom permission level

Run Set-PnPListPermission -Identity 'Documents' -Group 'Library Access' -AddRole 'Custom Permission'. Replace the library, SharePoint group, and role names with your existing names.

5
Review library access

Open the library in SharePoint and go to Settings > Library settings > Permissions for this document library. Confirm the group and permission level, and review any copied assignments.

Assign library access through a SharePoint group with PnP PowerShell
Check the SharePoint group's existing access: Adding the security group to a SharePoint group also gives it any other access already assigned to that SharePoint group. If the group claim cannot be resolved, verify that synchronization is complete and that you used the Entra object ID of a security group.
Free Microsoft Office alternative

Work with SharePoint library documents in WPS Office

WPS Office is a free, lightweight alternative for working with Office documents in a familiar interface. Its format compatibility helps you move existing files into your workflow, though SharePoint permissions must still be managed in SharePoint.

Edit documents and spreadsheets used in SharePoint librariesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Does the Active Directory group need to be synchronized?

Yes. For SharePoint Online to recognize the group, synchronize the AD security group to Microsoft Entra ID and use its Entra object ID in the group claim.

Will breaking inheritance remove existing library permissions?

The example uses -CopyRoleAssignments to retain inherited assignments when inheritance is broken. Review them under Library settings > Permissions for this document library.

Where do I create the custom permission level?

In the SharePoint site, open Site settings > Site permissions > Permission Levels. Create the level before using its name with Set-PnPListPermission.

Can adding the security group grant access elsewhere?

Yes. Members receive the access already assigned to the SharePoint group as well as the library permission added here. Review the SharePoint group's existing permissions before adding the security group.