Forum Discussion

Avi65's avatar
Avi65
Brass Contributor
Oct 05, 2023

How to remove all the users & SharePoint group from document library or list in SharePoint 2013?

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

  • Avi65 

    In 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:

    1. Navigate to the Document Library or List:
      • Go to the SharePoint site where your document library or list is located.
      • Navigate to the specific document library or list you want to manage.
    2. Access Library/List Settings:
      • In the document library or list, click on the "Library" or "List" tab in the ribbon at the top.
      • Click on "Library Settings" or "List Settings," depending on your version of SharePoint.
    3. Manage Permissions:
      • Under the "Permissions and Management" section, click on "Permissions for this document library" or "Permissions for this list."
    4. Remove Users/Groups:
      • You will see a list of users and groups with their respective permissions. Find the users or groups you want to remove.
      • Check the checkbox next to the users or groups you want to remove.
      • Click on the "Remove User Permissions" button (a trash can icon) in the ribbon.
    5. Confirm Removal:
      • SharePoint will ask you to confirm the removal of permissions. Confirm the action.
    6. Repeat as Needed:
      • You can repeat this process for each user or group you want to remove.

    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:

    • "http://YourSiteCollectionURL": Replace this with the URL of your SharePoint site collection.
    • "YourDocumentLibraryOrListName": Replace this with the name of the document library or list from which you want to remove users and groups.

    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.

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Avi65 

    In 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:

    1. Navigate to the Document Library or List:
      • Go to the SharePoint site where your document library or list is located.
      • Navigate to the specific document library or list you want to manage.
    2. Access Library/List Settings:
      • In the document library or list, click on the "Library" or "List" tab in the ribbon at the top.
      • Click on "Library Settings" or "List Settings," depending on your version of SharePoint.
    3. Manage Permissions:
      • Under the "Permissions and Management" section, click on "Permissions for this document library" or "Permissions for this list."
    4. Remove Users/Groups:
      • You will see a list of users and groups with their respective permissions. Find the users or groups you want to remove.
      • Check the checkbox next to the users or groups you want to remove.
      • Click on the "Remove User Permissions" button (a trash can icon) in the ribbon.
    5. Confirm Removal:
      • SharePoint will ask you to confirm the removal of permissions. Confirm the action.
    6. Repeat as Needed:
      • You can repeat this process for each user or group you want to remove.

    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:

    • "http://YourSiteCollectionURL": Replace this with the URL of your SharePoint site collection.
    • "YourDocumentLibraryOrListName": Replace this with the name of the document library or list from which you want to remove users and groups.

    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.

Resources