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:
- Go to the document library in question.
- Click on the gear icon in the top right corner and select "Library settings".
- Under "Permissions and Management", click on "Permissions for this document library".
- Find the user you want to remove as an owner and click on the checkbox next to their name.
- Click on the "Remove User Permissions" button in the ribbon at the top of the page.
For more information, please refer to:
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:
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.