Friday, August 16, 2013

Remove Site Collection Administrator using PowerShell

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



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...