Oct 05 2023 08:15 AM - edited Oct 05 2023 08:20 AM
Hello
We have individua users and groups in SharePoint Document Library.
How to remove all the users & SharePoint groups from a document library or list in SharePoint 2013 using PowerShell?
Avian
Oct 07 2023 05:21 AM
SolutionIn SharePoint 2013, you can remove individual users and groups from a document library or list directly through the SharePoint user interface without using PowerShell.
Here is how you can do it:
This method allows you to remove users and groups from the document library or list without using PowerShell. It provides a user-friendly way to manage permissions directly within the SharePoint web interface. However, keep in mind that this approach is manual and may be more time-consuming if you have a large number of users or groups to remove. PowerShell is more efficient for bulk operations.
You can use PowerShell to remove all users and SharePoint groups from a document library or list in SharePoint 2013. Here is a PowerShell script that can help you achieve this if is needed:
# SharePoint 2013 PowerShell Script to Remove All Users and Groups from a Document Library or List
# Add SharePoint PowerShell SnapIn if not already added
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# Specify your SharePoint site URL and document library or list name
$siteUrl = "http://YourSiteCollectionURL"
$listName = "YourDocumentLibraryOrListName"
# Get the site and document library or list
$web = Get-SPWeb $siteUrl
$list = $web.Lists[$listName]
# Loop through all users and groups in the document library or list
foreach ($roleAssignment in $list.RoleAssignments) {
$roleAssignment.RoleDefinitionBindings.RemoveAll()
$roleAssignment.Update()
}
# Dispose of SharePoint objects
$list.Dispose()
$web.Dispose()
Write-Host "All users and groups removed from the document library or list."
Make sure to replace the following placeholders with your own values:
After replacing the placeholders, run the script using SharePoint Management Shell or PowerShell with SharePoint Online Module installed. This script will remove all users and groups from the specified document library or list in SharePoint 2013. Please exercise caution when running such scripts, especially in a production environment, and ensure you have the necessary permissions to make these changes.
My knowledge of the topic is limited, but since no one has answered yet, even though it has been read many times, I posted the question in various AIs and found the above suggested solution for you. The proposed solution is untested.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.