Question

I am trying to create office 365 group through PowerShell. I am using New-Unified group function to achieve. Group is creating successfully but unfortunately site is not creating behind the scenes. Is this not the right way to do it?

I have also tried with MSOnline command New-SPOSite to create new modern site. But site is creating but group is not creating behind the scenes. What is wrong with this?

What is the proper way to do it?

Was it helpful?

Solution

You can create a Modern team site with associated O365 group using PnP PowerShell.

New-PnPSite -Type TeamSite -Title "Test Group" -Alias "TestGroup" -Description "Test group desc" -IsPublic

Reference - New-PnPSite

If you want create it via MS Graph, PnP PowerShell also supports that. You can provision the Group as below. You need to be Global admin to run this command AFAIK :

Connect-PnPOnline - Url "https://tenant.sharepoint.com" -Scopes @("Group.ReadWrite.All", "User.ReadWrite.All", "Directory.ReadWrite.All")

New-PnPUnifiedGroup -DisplayName "Test Group" -Description "Test my group" -MailNickname "Testgroup" -Owners "user@tenant.onmicrosoft.com" -Members "user@tenant.onmicrosoft.com"

New-PnPUnifiedGroup

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top