Microsoft 365 – SharePoint Online – Creating new SharePoint group using PnP PowerShell

Hi All,
Greetings for the day!!
Today sharing PnP PowerShell CMDLET for creating SharePoint group which I used in one of the SharePoint online project
SharePoint group
- A SharePoint group is collection / set of users
- SharePoint group allows us to manage these set of users rather individual users
Details / Background / Usecase
- We are creating multiple site collections using PnP site provisioning engine
- We have created our custom template and using it for creating new site collections
- One of our requirement is to have our custom SharePoint group
- While applying template I noticed that for some reason, for some sites creating custom group is failing
- Though its in template which we generated
- So thought to create explicitly after template is applied successfully and so here is the article
Previously I already have an article – how to create SharePoint group in modern site collection using PowerShell – Microsoft 365 : SharePoint Online – PowerShell script – PowerShell script to create SharePoint group in a given site collection
In this article we will discuss – how to create SharePoint group in modern SharePoint online sites using PnP PowerShell
STEPS to create Group in SharePoint Online modern communication site using PnP PowerShell
- Connects PnP online using – Connect-PnPOnline
- Connect to the the site where we need to create our custom group
- Here we will be creating our custom group “KnowledgeJunction Distributors” in my local tenant, on root site – https://knowledgejunction1.sharepoint.com
- Before executing or moving ahead, currently groups available on my root site are as

Connect-PnPOnline -Url https://knowledgejunction1.sharepoint.com
- Once we successfully connected to SharePoint Online / PnP Online, next step is use the PowerShell CMDLET to create new group – New-PnPSiteGroup
- Syntax for New-PnPSiteGroup
New-PnPSiteGroup
-Name <String>
-PermissionLevels <String[]>
[-Site <SitePipeBind>]
Where,
–Name: group name
–PermissionLevels – Permission levels to grant the newly created group.
- We can navigate to permission level page – /_layouts/15/role.aspx, here in our case complete URL is – https://knowledgejunction1.sharepoint.com/_layouts/15/role.aspx?Source=https%3A%2F%2Fknowledgejunction1%2Esharepoint%2Ecom%2F%5Flayouts%2F15%2Fuser%2Easpx
- OOB permission levels are
- Full Control
- Design
- Edit
- Contribute
- Read

- Lets create our custom group “KnowledgeJunction Distributors” on our root site – https://knowledgejunction1.sharepoint.com/ with permissions “Full Control” as
New-PnPSiteGroup -Site https://knowledgejunction1.sharepoint.com -Name "KnowledgeJunction Distributors" -PermissionLevels "Full Control"

- After successfully execution of “New-PnPSiteGroup” CMDLET we have our new custom group is in place as

Complete Script
PS C:\> Connect-PnPOnline -Url https://knowledgejunction1.sharepoint.com
WARNING:
A newer version of PnP PowerShell is available: 2.2.0.
Use 'Update-Module -Name PnP.PowerShell' to update.
Use 'Get-PnPChangeLog -Release 2.2.0' to list changes.
You can turn this check off by setting the 'PNPPOWERSHELL_UPDATECHECK' environment variable to 'Off'.
PS C:\> New-PnPSiteGroup -Site https://knowledgejunction1.sharepoint.com -Name "KnowledgeJunction Distributors" -PermissionLevels "Full Control"
LoginName : KnowledgeJunction Distributors
Title : KnowledgeJunction Distributors
OwnerLoginName : prasham@knowledgejunction1.onmicrosoft.com
OwnerTitle : Prasham Sabadra
Users : {}
Roles : {Full Control}

REFERENCES
- Connect-SPOService
- Connect-PnPOnline
- How to create SharePoint group in modern site collection using PowerShell
Thanks for reading !!! HAVE a FANTASTIC LEARNING AHEAD 🙂
You must log in to post a comment.