Forum Discussion
Possible to set default Members group for a site with PowerShell?
Hello,
does anyone know if it's possible to set a default Members group via PowerShell?
The reason I'm asking is because we've identified a couple of sites lacking the default Members group. It looks like this:
I know that there's the option to set any group as the default Members group by going into the group choosing:
But, is there a way to to this with PowerShell?
So far I have only found the equivalent method to _layouts/15/permsetup.aspx which is CreateDefaultAssociatedGroups() (see https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spweb.createdefaultassociatedgroups?view=sharepoint-server).
However, this only creates the three default associated groups if not already present.
In many of our cases, the default groups do exist in the site already:
They're simply not associated, i.e. none of these three groups is associated with the default members group.
I hope I was able to explain my issue clearly and I'm looking forward to your comments.
4 Replies
- Deleted
Bumping this as I'm time and again running into that issue that I have to change the default sharing group for a lot of sites. Still can't find a way how to achieve this. Has anyone ever found a solution for this? Thanks.
- JamesOrtonCopper Contributor
Hi Deleted
Try Set-PnPGroup -Identity 'My Site Members' -SetAssociatedGroup Members
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnpgroup?view=sharepoint-ps
- Steven AndrewsIron Contributor
Deleted
This is a very good question. I don't have the developmental skills myself to whistle something up today but I do believe that it's possible. The PermSetup.aspx page when it's utilised sets three site parameters of (AssociatedOwnerGroup, AssociatedMemberGroup and AssociatedVisitorGroup).
Looking at the members of the Get-SPOSite command I don't see these as being available to manipulate, which I suspect rules out the SharePoint Online PowerShell Module.
I have seen an article on SharePoint Stackexchange that suggests this is possible via the SharePoint CSOM, which can be read here. Hope that's of some use.
- colonel_claypooIron Contributor
Steven Andrews, thanks for the pointers, that should help. I was also given this link which could be helpful: https://stackoverflow.com/questions/32760558/csom-set-make-default-group
Will test out when I have the time, thanks.