Introduction
In this blog, I will explain all the basic commands we need to Get SharePoint Groups, Set SharePoint Groups and Create SharePoint Groups using PNP. These commands are applicable to SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019, SharePoint Online.
Get-PnPGroup:
1. Get-PnPGroup
It returns a specific Sharepoint group or else returns all "Sharepoint Group" in the site.
There are many Syntaxes of it which are described below:
2. Get-PnPGroup -Identity 'My Softree Users'
This will return the group called 'My Softree Users ' in if available in the current site.
3. Get-PnPGroup -AssociatedMemberGroup
This will Return the associated member group
4. Get-PnPGroup -AssociatedVisitorGroup
This will Return the associated visitor group.
5. Get-PnPGroup -AssociatedOwnerGroup
This will Return the associated owner group.
New-PnPGroup:
1. New-PnPGroup -Title "My Softree Users"
This will create the “My Softree Users” group in the current site.
2. New-PnPGroup -Title "My Softree Users" -AllowMembersEditMembership
This will specify whether group members can modify membership in the group.
3. New-PnPGroup -Title "My Softree Users" -AllowRequestToJoinLeave
This will specify whether to allow users to request membership in the group and to allow users to request to leave the group.
4. New-PnPGroup -Title "My Softree Users" -AutoAcceptRequestToJoinLeave
This will specify whether users are automatically added or removed when they make a request
5. New-PnPGroup -Title "My Softree Users" -DisallowMembersViewMembership
This will disallow group members to view membership.
Remove-PnPGroup:
1.Remove-PnPGroup -Identity "My Softree Users"
This will remove the group "My Softree Users".
Conclusion:
In this blog, I have covered the various commands we need to Create a SharePoint Group, Get a SharePoint Group, and Remove a SharePoint Group using PnP.