How to add permissions to all sub folders having unique permissions using pnp powershell with looping through all folders?

Chandra Kishore Bodduru 1 Reputation point
2021-06-12T17:09:33.977+00:00

Hello,

How can we use this option which is in SharePoint Online UI (share everything in this folder, even with unique permissions) with pnp powershell?

105074-image.png

Microsoft 365 and Office | SharePoint | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Echo Du_MSFT 17,316 Reputation points
    2021-06-14T03:06:28.943+00:00

    Hello @Chandra Kishore Bodduru ,

    Welcome to Q&A Forum!

    Please run the below PNP PowerShell as an admin:

    #Config Variables  
    $SiteURL = "https://tenant.sharepoint.com/sites/sitename"  
    $ListName ="listname"  
    $FolderServerRelativeURL = "/Sites/sitename/listname/foldername"       
    #Connect to PnP Online  
    Connect-PnPOnline -Url $SiteURL -UseWebLogin  
    #Set folder permissions - Add User  
    Set-PnPfolderPermission -List $ListName -identity $FolderServerRelativeURL -User "******@tenant.onmicrosoft.com" -AddRole "Edit"  
    

    105232-3.png

    105233-4.png

    Thanks,
    Echo Du

    ==============================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.