question

ChandraKishoreBodduru-4014 avatar image
0 Votes"
ChandraKishoreBodduru-4014 asked EchoDu-MSFT commented

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

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


office-sharepoint-onlinewindows-server-powershell
image.png (22.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

EchoDu-MSFT avatar image
0 Votes"
EchoDu-MSFT answered EchoDu-MSFT commented

Hello @ChandraKishoreBodduru-4014 ,

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 "username@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.





3.png (49.5 KiB)
4.png (108.5 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@EchoDu-MSFT Thank you for reverting. Small correction in my question.

Corrected Question: How to add permissions to all sub folders (Having unique permissions) under a top level folder having unique permissions using pnp powershell without looping through all sub folders?

I have a solution that loops through all the subfolders and adds the permissions. But we are dealing with thousands of folders and this is a time taking process. I saw an option in SP Online UI saying "share everything in this folder, even with unique permissions."
I'm looking if there is a way to use this in powershell so that without looping through all the sub folders under a folder we can add the permissions.

Thank you,
Chandra Kishore


0 Votes 0 ·
EchoDu-MSFT avatar image EchoDu-MSFT ChandraKishoreBodduru-4014 ·

Hi @ChandraKishoreBodduru-4014 ,

Thanks for your reply.

Based on my research, there is no way to meet your design through PNP PowerShell.

You can see the "Sharing SharePoint folder items with unique permissions" to learn more information.

Thanks,
Echo Du



0 Votes 0 ·
EchoDu-MSFT avatar image EchoDu-MSFT ChandraKishoreBodduru-4014 ·

Hi @ChandraKishoreBodduru-4014 ,

Is there anything else I can help with regarding this issue?

You can comment us at any time and we will continue to follow up.

Thanks,
Echo Du

0 Votes 0 ·