0

I am trying to remove a cached user account added in more than 18000 sites. for that I have been trying below PNP script:

$displayName = "DisplayNameOfAccountThatNeedTobeRemoved"
    
Get-PnPTenantSite | ForEach-Object {
   $site = $_
   Write-Host "Processing $($site.Url)..."
   Connect-PnPOnline $site.Url -Credentials $creds
   Get-PnPUser | ? Title -like $displayName | Remove-PnPSiteCollectionAdmin
}

But it is giving me an error "Access denied. You do not have permission to perform this action or access this resource."

I have also tried Remove-SPOUSer cmdlet too but it is giving me same error message.

I cannot add my account as a site collection admin on all the sites due to compliance and efficiency purposes. I do have SharePoint admin rights though.

1 Answer 1

0

By default, user information list is only visible and accessible by each site collection administrators.

I don't think it's possible to remove a user account from user information list without being a site collection administrator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.