I am using PowerShell to create site collections, and add users by code. I add users as visitors, contributors and as owners. In my powershell code I can get both the Visitors and Contributors group, but Owners Group is always null. I can not understand why. Please advice. This is my code snippet. $web.AssociatedOwnersGroup always returns null

function Add-UsersToSpGroup ( $url, $listItemUsers, $PermissionsGroup )
    $web = Get-SPWeb $url
    $Users = $listItemUsers
    if($PermissionsGroup -eq "Owners")
        $Group = $web.AssociatedOwnersGroup;
    elseif($PermissionsGroup -eq "Members")
        $Group = $web.AssociatedMemberGroup;

I am using SP 2013 on-prem.

  • Did you check if the Owner group actually exist on your site collection first? use this at the end of your url to see _layouts/15/permsetup.aspx – Ahmed Mahmoud May 18 '16 at 19:36
  • yep, it exists. What happens by clicking "ok" in here. Does it trigger "CreateDefaultAssociatedGroups" ? – Ilyas May 18 '16 at 19:40
  • my understanding the AssociatedOwnerGroup has to be null before invoking CreateDefaultAssociatedGroups method. so you should do something like $web.AssociatedOwnerGroup = $null before $web.CreateDefaultAssociatedGroups($web.Site.Owner.UserLogin, $web.Site.SecondaryContact.UserLogin, $web.Title) – Ahmed Mahmoud May 18 '16 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.