PowerShell Script to Reset Permissions on all Documents in a Document Library in SharePoint Online. Here's a PowerShell script that resets permissions on all documents in a SharePoint Online document library: #Connect to SharePoint Online Site $SiteURL = "https://yourdomain.sharepoint.com/sites/sitename" $UserName = "[email protected]" $Password = "yourpassword" $SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential($UserName, $SecurePassword) Connect-PnPOnline -Url $SiteURL -Credentials $Cred #Set Variables $ListName = "Documents" $FolderPath = "/Shared Documents" #Get all Documents from the document library $Documents = Get-PnPListItem -List $ListName -Folder $FolderPath #Loop through each document and reset permissions foreach ($Doc in $Documents) { Set-PnPListItemPermission -List $ListName -Identity $Doc.Id -InheritPermissions $true -ClearAllPermissions $true } Write-Host "Permissions reset complete." You will need to replace the following placeholders with the appropriate values: https://ift.tt/oDqM4Lr - the URL of your SharePoint Online site [email protected] - your username for the SharePoint Online site yourpassword - your password for the SharePoint Online site Documents - the name of your document library /Shared Documents - the path to the folder containing the documents that you want to reset permissions for Once you have updated the placeholders with the appropriate values, save the script as a .ps1 file and run it in PowerShell. The script will loop through each document in the specified folder and reset the permissions to inherit from the parent folder. via Blogger https://ift.tt/tOaijkA 2023-03-17T11:51:00-09:00












