2

How can i set existing SharePoint Group as Group Owner (instead of SPUser, set SPGroup as owner) using PowerShell at the time of creation of new Group?

3 Answers 3

0

Use the below code,

Add-PSSnapin Microsoft.SharePoint.PowerShell

$web = Get-SPWeb URL
$GroupName = "GroupName"
$Ownergroup = $web.SiteGroups["OwnerGroupName"]
$Description = "Enter the description"
$member = $web.SiteUsers["domain\username"]
$web.SiteGroups.Add($GroupName, $Ownergroup, $member, $Description)
$web.Update();

Remove-PSSnapin Microsoft.SharePoint.PowerShell

Note:

  1. Please, change the URL of the web

  2. Please, change the "OwnerGroupName" to your respective group name.

  3. Instead of user, you can also assign a group for members, change the "domain\username"

1
  • Please feel free to mark it as answer, if it has helped you because it might help someone in future too :) . For more information, please drop a comment, Jan 19, 2016 at 7:58
0
#Get the SPWeb
$web = Get-SPWeb http://url_to_web

#Get the Group
$group = $web.SiteGroups["Target Group Name"]
$existingGroup = $web.SiteGroups["Existing Group Name"]

#Assign that user as the owner
$group.Owner = $existingGroup

#Update the Group
$group.Update()

Ideally this should be enough for it. If doesn't work, type cast $existingGroup group as a user. and assign to the $group.Owner

I am assuming both groups are already created, and you are updating permissions now.

PS: It is not tested since I don't have test environment available right now to test it.

0

If you want it in SPO, you can do it via PNP PowerShell

Connect to your SharePoint site

Connect-PnPOnline -Url "https://your-sharepoint-site-url" -Credentials (Get-Credential)

Retrieve the SharePoint group that you want to set as owner

$sharePointGroup = Get-PnPGroup -Identity "Your SharePoint Group Name"

Retrieve the SPGroup (SharePoint group) that you want to update

$spGroup = Get-PnPGroup -Identity "Your SPGroup Name"

Set the SharePoint group as the owner of the SPGroup

$spGroup.SetOwner($sharePointGroup)

Update the SPGroup

$spGroup.Update()

Execute the pending operations

Invoke-PnPQuery

Additional resources from here

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.