Saturday, April 23, 2016

How to Change SharePoint Group Owner using PowerShell

Change group owner in sharepoint site:
Follow these steps to update sharepoint group owner in SharePoint.

  • Go to Site Settings >>  People and Groups
  • Pick the group you want from the Left navigation
  • From the group page, Click on Settings >> Group Settings >> Set the new group owner in "Group Owner" field. Hit OK to save your changes. This changes owner of the group.
how to change sharepoint group owner powershell
Changing the group owner from SharePoint web user interface is quite simple. But At times, you may have to replace an existing group owner with a new user across multiple site collections. Ideally, we have to leverage PowerShell for these kind of admin tasks.

How to change SharePoint Group owner using PowerShell?
Here is the SharePoint PowerShell to update group owner.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Parameters
$SiteURL="http://intranet.crescent.com/Sites/Operations"
$GroupName="Operations Site Owners"
$GroupOwner="Crescent\Salaudeen"

Try {
    #Get the Site and Group
    $Web = Get-SPWeb $SiteURL
    $Group = $web.SiteGroups[$GroupName]

    if ($Group -ne $null)
    {  
        #Get the User 
        $Owner = $web.EnsureUser($GroupOwner)

        #change group owner
        $Group.Owner = $Owner

        #Update the Group
        $Group.Update()
        Write-host -f Green "Group Owner updated successfully!"
    }
    else
    { 
        Write-host -f Yellow "Group Doesn't Exists!" 
    }
}
Catch {
    write-host -f Red "Error Changing Group Owner!" $_.Exception.Message
}
This PowerShell script changes group owner programmatically for the given group name. By default, you can specify only one user as a Group owner, So its a good idea to set group owner to Farm Admin account or use SharePoint group as Group owner!

Update sharepoint group owners for all groups using PowerShell:
While the above script changes the group owner for given group name, Lets change group owners for all groups in the entire site collection. Here is the PowerShell script to set group owner for all groups in the site collection.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Parameters
$SiteURL="http://intranet.crescent.com/Sites/Sales"
$GroupOwner="Crescent\Salaudeen"

Try {
    #Get all sites under given Site Collection
    $WebsCollection =  Get-SPSite $SiteURL | Get-SPWeb -Limit ALL
    
    #Loop through each web
    Foreach ($Web in $WebsCollection) 
    {
        Write-Host -f Yellow "Processing Web:"$Web.URL
        
        #Process the sites with unique permissions
        If($Web.HasUniqueRoleAssignments)
        {
            #Get the Group Owner User
            $Owner = $Web.EnsureUser($GroupOwner)

            #Get all Groups and Iterate through
            Foreach ($Group in $Web.Groups)
            {
                #Update the group owner                    
                $Group.Owner = $Owner
                $Group.Update()
                Write-host -f Green "Group Owner Updated for "$Group.Name
            }
        }
    }
}
Catch {
    write-host -f Red "Error Changing Group Owner!" $_.Exception.Message
}
Although this script is written to change all group owners for given site collection, With slight changes to this script, You change the Group Owners of SharePoint Groups for any number of site collections. You can also change the script a bit to change owner of group for a entire web application or even all web applications in the farm. Just change $WebsCollection to:
$WebsCollection =  Get-SPWebApplication | Get-SPSite  -Limit ALL | Get-SPWeb -Limit ALL
Tips: You can also assign an existing SharePoint group as a group owner in SharePoint! Here is how:
$GroupOwner = $web.SiteGroups["Sales Site Owners"]

Tags: sharepoint group owner change, sharepoint change group owner powershell, sharepoint edit group owner, how to change sharepoint group owner, change sharepoint group owner via powershell, update sharepoint group owner powershell



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...