kwizcom banner advertisement

Remove Site Collection Administrator in SharePoint using PowerShell

Site collection administrators are administrators of the site collection with full control to the entire site collection including top-level site and all of its subsites, lists and libraries in the site collection.

How to Remove 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 to Remove Site Collection Administrator:
We may have to remove site collection administrators programmatically. Lets use PowerShell in SharePoint to remove site collection administrator:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Remove-SiteCollAdmin($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
Remove-SiteCollAdmin "Domain\UserAccount" "http://sharepoint.crescent.com/"
Note that, You can't leave site collection Administrators empty! Usually primary/secondary site collection administrators are assigned through SharePoint Central Administration site. If you want to change a Primary/Secondary Site collection administrator using Central Administration/PowerShell/Stsadm tool, refer my post: How to Change Site Collection Primary, Secondary Administrators in SharePoint

Tags: sharepoint remove site collection administrator, powershell remove site collection admin, remove secondary site collection administrator powershell, remove site collection administrator powershell
Remove Site Collection Administrator in SharePoint using PowerShell Remove Site Collection Administrator in SharePoint using PowerShell Reviewed by Salaudeen Rajack on August 16, 2013 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.