unable to remove document library owner

HK G 516 Reputation points
2023-10-06T21:00:39.6733333+00:00

We assigned an admin as a site owner for a particular project on a SP) site. The project was completed and we removed his SPO site ownership. However, I noticed that his account still listed as owner on different document libraries. I tried to remove it but there didn't seem to be an option either from the site portal or through the pnp.powershell module.

Any suggestions how I can remove that ownship?

Thanks

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-10-09T08:23:33.2033333+00:00

    Hi @HK G ,

    First, check the user's permission at the site level to ensure that he is no longer the site owner.

    Then, remove the permissions in the library. You can try the following two methods:

    1, To remove an owner from a document library in SharePoint Online, you can follow these steps:

    1. Go to the document library in question.
    2. Click on the gear icon in the top right corner and select "Library settings".
    3. Under "Permissions and Management", click on "Permissions for this document library".
    4. Find the user you want to remove as an owner and click on the checkbox next to their name.
    5. Click on the "Remove User Permissions" button in the ribbon at the top of the page.

    For more information, please refer to:

    https://support.microsoft.com/en-us/office/customize-permissions-for-a-sharepoint-list-or-library-02d770f3-59eb-4910-a608-5f84cc297782

    2, Using PowerShell:

    #Config Variables
    $SiteURL = "https://tenant.sharepoint.com/sites/sitename"
    $ListName ="libraryname"
    $UserID= "i:0#.f|membership|******@tenant.onmicrosoft.com"
    
     
    #Connect PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
     
    #Get the Context
    $Context = Get-PnPContext
      
    #Get the list & User objects
    $List = Get-PnPList -Identity $ListName
    $User = Get-PnPUser -Identity $UserID
     
    #Break Permission Inheritance
    Set-PnPList -Identity $ListName -BreakRoleInheritance -CopyRoleAssignments
     
    #Remove User from List Permissions
    $List.RoleAssignments.GetByPrincipal($User).DeleteObject()
    $Context.ExecuteQuery()
    

    For more information, please refer to:

    https://www.sharepointdiary.com/2018/04/sharepoint-online-remove-user-group-from-list-permissions-using-powershell.html

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.