Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Remove Site Collection Administrator using PowerShell

$
0
0
How to remove a site collection administrator in SharePoint? To remove SharePoint Site Collection Administrator, we use "Site collection Administrators" link from site settings.
remove site collection administrator
You must be a Farm Administrator or site collection administrator to see this link, BTW! From this page, we can delete site collection administrators.
remove site collection administrator powershell

PowerShell Script to Remove Site Collection Administrator:
We may have to remove site collection administrators programmatically. Lets use PowerShell in SharePoint to remove site collection administrator:
Function RemoveSiteCollAdmin($AdminID, $SiteCollectionURL)
 {
 #Get the site collection
 $site = Get-SPSite $SiteCollectionURL

 #Get the Admin to remove from Site collection Administrator Group
 $Account = $site.RootWeb.SiteAdministrators | where {$_.UserLogin -eq $AdminID}
 
    #if User account found
 if($Account)
 {
  $Account.IsSiteAdmin = $false
  $Account.Update()
  Write-Host "$($AdminID) has been removed from Site Collection Administrator Group!"
 }
 else
 {
  Write-Host "$($AdminID) Not found in Site Collection Administrator Group!"
 }
}

 #Call the function to remove Site collection Admin
 RemoveSiteCollAdmin "Domain\UserAccount" "http://sharepoint.crescent.com/"

Note that, Primary Site collection administrator can't be removed and can be only changed! If you want to change a Primary Site collection administrator using Central Administration/PowerShell/Stsadm tool, refer my post: How to Change Site Collection Primary, Secondary Administrators in SharePoint


Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>