SharePoint Asked by Fjay on September 3, 2020
I have a document library with many users, some have full access, some have limited access and some have other combinations.Note, The library has a lot of subfolders with unique permission.
I want the entire document library to become read only, Whts the easiest way to do this pls ?
thanks
You can remove the unique permissions (folder and item level) in this document library using PowerShell. Then you can break inheritance on library level and give it View Only or Read permission to everyone.
Here is a sample script for your references:
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
#Variables for Web URL, List Name
$WebURL = "<SiteURL>"
$ListName = "<ListName>"
#get the list object
$List = (Get-SPweb $WebURL).lists.TryGetList($ListName)
#Reset Folder level inheritance
foreach ($folder in $list.Folders) {
if ($folder.HasUniqueRoleAssignments){
Write-Host "Resetting Folder inheritance at:" $folder.Url -fore Yellow
$folder.ResetRoleInheritance()
$folder.Update()
}
}
#Remove unique permissions on List Items
$ListItems = (Get-SPweb $WebURL).lists.TryGetList($ListName).Items | Where {$_.HasUniqueRoleAssignments}
Foreach($ListItem in $ListItems){
$ListItem.ResetRoleInheritance()
Write-host "Broken Inheritance Reset on List Item:" $ListItem.URL -fore Yellow
}
Write-host "Reset Inheritance completed." -fore Green
Reference: Delete Unique Permissions (Reset Broken Inheritance) in SharePoint 2013 using PowerShell.
Another reference on how to set the library to Read Only using PowerShell: How to Make a SharePoint List or Library to Read Only Mode using PowerShell?
Correct answer by Chelsea_MSFT on September 3, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP