SharePoint Online: Check If a Folder has Unique Permissions

Requirement: Check If a Folder has Unique Permissions in SharePoint Online using PowerShell.

Powershell to Check If a Folder has Unique Permissions in SharePoint Online

How to check if a Folder has Unique Permissions?

By default, a new folder will have permissions inherited from its parent folder or library. Checking if a folder has unique permissions in SharePoint Online can be done by following these simple steps. This process will help ensure that all users have the correct level of access to the folders and files within the folder in your SharePoint site. Let’s look at how to check if the folder has unique permissions in SharePoint Online.

  1. Browse to the location where the specific folder is located.
  2. Select the folder, click on the “i” button to open the Information panel. Click on the “Manage Access” link.sharepoint online folder unique permissions
  3. Click on the “Advanced” link in the “Manage access” Pane.
  4. If the folder has unique permissions, You’ll see the “This folder has unique permissions.” message on the top area.sharepoint online view folder permissions

Check if a Folder has Broken Permission Inheritance using PowerShell CSOM

When granting permissions to folders and files in SharePoint Online, it’s important to ensure that the folder has unique permissions. In this guide, we’ll see how to check if a folder has unique permissions in SharePoint Online using PowerShell.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

$SiteURL = ""
$FolderServerRelativeURL = "/sites/marketing/Branding/2018"

Try {
    #Get Credentials to connect
    $Cred= Get-Credential
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
    #Get the Folder
    $Folder = $Ctx.Web.GetFolderByServerRelativeUrl($FolderServerRelativeURL)
    #Check if Folder has unique permissions
    Write-host -ForegroundColor Green "Folder has unique Permissions:" $Folder.ListItemAllFields.HasUniqueRoleAssignments
Catch {
    write-host -f Red "Error:" $_.Exception.Message

PowerShell to Check If Folder has Unique Permissions:

You can quickly check if a folder has unique permissions using PnP PowerShell as:

$SiteURL = ""
$FolderServerRelativeURL = "/sites/marketing/Shared Documents/2018"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get Folder has unique permissions
$Folder = Get-PnPFolder -Url $FolderServerRelativeURL -Includes ListItemAllFields.HasUniqueRoleAssignments
Write-Host $Folder.ListItemAllFields.HasUniqueRoleAssignments 

Get Permissions of All Folders in SharePoint Online Library:

How about checking unique permissions for all folders in a document library?

$SiteURL = ""
$ListSiteRelativeURL = "/Shared Documents"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get Folder permissions recursively
Function Get-FolderPermissions($FolderURL)
    #Get all sub-folders of the Folder
    $SubFolders = Get-PnPFolderItem -FolderSiteRelativeUrl $FolderURL -ItemType Folder | Where {$_.Name -ne "Forms" -and $_.Name -ne "Document"} 
    #Loop through the sub-folders
    ForEach($SubFolder in $SubFolders)
        #Calculate site relative URL of the Folder
        $SubFolderURL = $FolderUrl+"/"+$SubFolder.Name

        #Get Folder HasUniqueRoleAssignments property
        $Folder = Get-PnPFolder -Url $SubFolder.ServerRelativeUrl -Includes ListItemAllFields.HasUniqueRoleAssignments
        Write-Host "Folder '$($SubFolder.ServerRelativeUrl)' has unique permissions:" $Folder.ListItemAllFields.HasUniqueRoleAssignments

        #Call the function recursively
        Get-FolderPermissions $SubFolderURL
#Call the function
Get-FolderPermissions $ListSiteRelativeURL

By following the steps outlined in this tutorial, you should now be able to use PowerShell to check if a specific folder in SharePoint Online has unique permissions. Similarly, to get all list items with unique permissions, refer: SharePoint Online: Get All List Items with Unique Permissions using PowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *