1.Create a csv file as following picture show.
2.Run following PowerShell as administrator to set permissions for folder.
$SiteURL = "https://tenant.sharepoint.com/sites/emily"
$Documentlibrary = "doc"
$CSVFile = "C:\Users\spsetup\Desktop\pnp.csv"
Connect-PnPOnline -Url $SiteURL -Interactive
$CSVData = Import-CSV $CSVFile
ForEach($Row in $CSVData)
{
#Get the user
$Users = $Row.User
ForEach($User in $Users)
{
Set-PnPfolderPermission -List $Documentlibrary -identity $Row.FolderServerRelativeURL -User $User -AddRole $Row.Permission
}
}
3.Result:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.