Hi @Jindriska ,
To grant permissions to files in batches, you can use a PowerShell script to make it.
The following script example gives permissions to all files in a library:
#Set Variables
$SiteURL = "https://tenant.sharepoint.com/sites/sitename"
$ListName="Documents"
$ParentFolderURL = "/Shared Documents" #Site Relative Path of the document Library
$GroupName
$Role = "Edit"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get all Files from the Folder
$AllFiles = Get-PnPFolderItem -ItemType File -FolderSiteRelativeUrl $ParentFolderURL
#Iterate through each File in the Folder
ForEach($File in $AllFiles)
{
#Grant permissions to the File
Set-PnPListItemPermission -List $ListName -Identity $File.ListItemAllFields -User $UserAccount -AddRole $Role
Write-host ("Granted Permission to '{0}' at {1} " -f $File.Name,$File.ServerRelativeUrl)
}
#Read more: https://www.sharepointdiary.com/2019/01/sharepoint-online-grant-permission-to-all-files-in-a-folder-using-powershell.html#ixzz8GHOruoFl
If the files you need to operate are only part of the library, there are to choices you can try:
1, You can choose to put their names into the csv file and then grant permissions. The changes to the script are as follows:
Add statement:
#SetVariables
$file = "C:\Users\spadmin\Desktop\csvfile.csv"
#Get the CSV file
$csv = Import-CSV $file
Remove statement:
$AllFiles = Get-PnPFolderItem -ItemType File -FolderSiteRelativeUrl $ParentFolderURL
2, You can put these files into one folder, so that you only need to change the $ParentFolderURL
parameter in this script can be done.
For more details, please refer to:
https://www.sharepointdiary.com/2019/01/sharepoint-online-grant-permission-to-all-files-in-a-folder-using-powershell.html
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.