How to Create an Office 365 Group using PowerShell?

Requirement: Create New Office 365 Group using PowerShell.

How to Create an Office 365 Group in the Admin Center?

Microsoft 365 Group is a collaboration feature that enables teams to work together by establishing a single identity and a single set of permissions across Microsoft 365 apps, including group inbox, Shared Document Library from SharePoint, Yammer, OneNote, Planner, Power BI, etc. By default, anyone in your organization can create a new Microsoft 365 group from Outlook Desktop or Online. You can create Office 365 groups through Microsoft 365 admin center as an Administrator:

  1. Log in to the Microsoft 365 Admin Center site as global admin:
  2. Expand “Teams & Groups” and Click on “Active Teams & Groups” in the left navigation.
  3. Click on “Add a Group” under the “Office 365” tab. 
    create office 365 group
  4. Select the group type as “Microsoft 365” in the wizard and click on Next. You can also create other group types like security group, email distribution list, etc. from this wizard.
  5. Enter the group name and description and click on “Next”.
    powershell to create office 365 group
  6. Click on “Add Owners” >> Search and select the group owners to manage the group. Click on “Next”.
    how to create a group in office 365
  7. Similarly, select group members and then click on the Next button.
  8. Enter a unique email address for the group. Specify the privacy option for the Office 365 Group. Set if the group should have a Microsoft Teams and click on “Next”.
    how to create an office 365 group
  9. Review all your settings and click on the “Create Group” button to start creating the Office 365 group.

Once we’ve created a group, all related resources, such as Shared mailbox, Calendar, SharePoint Site, etc., get provisioned automatically. Also, when you create artifacts like the SharePoint Team site, and create a new Team in the Microsoft Teams admin center, Yammer, Power BI, etc., the group creation happens automatically behind the scenes. You can also add a group from the Exchange Admin center.

Let’s see how to create an Office 365 group via PowerShell.

How to Create Office 365 Group using PowerShell?

Compared with the web browser interface, creating an Office 365 group through PowerShell allows you to have more control over the Group properties with additional settings. To create an Office 365 Group, first, you need to establish a remote session to Exchange Online and then use the New-UnifiedGroup cmdlet to create an Office 365 Group with PowerShell.

Open Windows PowerShell and run the following script:

#Get Credentials to connect
$Credential = Get-Credential
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False

#Create New Office 365 Group
New-UnifiedGroup -DisplayName "Consumers Group" -Alias "0365Group-consumers" `
        -EmailAddresses "" -AccessType Private

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

This creates a new private group called “Consumers Group” with an email address of “”.

create office 365 group using powershell

The parameters used in this cmdlet are self-explanatory. They define the properties of the group:

  • DisplayName: The Display name of the group, is the minimum parameter to create a group.
  • Alias: Exchange alias for the group. If you don’t supply the value for this parameter, it will be generated.
  • EmailAddresses: The e-mail address of the Group.
  • AccessType: Public or Private.  

Numerous other parameters allow you to customize things even further, which are unavailable in UI!

Add a Microsoft 365 Group using PnP PowerShell

Use the New-PnPMicrosoft365Group cmdlet to add a new Office 365 group:

#Config Variables
$AdminSiteURL = ""

Try {
#Connect to PnP Online
Connect-PnPOnline -Url $AdminSiteURL -Interactive

#Create a new Office 365 group
New-PnPMicrosoft365Group -DisplayName "HR Admins" -Description "For HR Administrators" -MailNickname "HRAdmin" `
    -Owners "" -Members @("","") -IsPrivate

Catch {
    write-host -f Red "Error:" $_.Exception.Message

Set the parameters like the Admin site URL, Group Name, Owner of the group and members, etc., according to your requirements. To make the group privacy to private, use “-IsPrivate” switch.

Create New Office 365 Group using Azure AD PowerShell Module

You can create a new group in Office 365 using the Azure Active Directory module as well. Here is an example:

#Connect to Azure AD

#Create new Office 365 group
New-AzureADMSGroup -DisplayName "Accounts Group" -MailNickname "Accounts" -GroupTypes "Unified" -Description "Office 365 Group for Accounts Departmnet" -MailEnabled $True -SecurityEnabled $True

When the “Connect-AzureAD” cmdlet prompts for credentials, Enter your Office 365 Admin account!

Wrapping up

Creating an Office 365 group is a simple process that can be done using either the Microsoft 365 admin center or PowerShell. By following the steps outlined in this guide, you can quickly create a new group and begin collaborating with your team. You can also create Office 365 groups using Microsoft Outlook, Azure AD Admin center, etc. The steps outlined in this guide will help you create a new group quickly, so you can start collaborating with your team right away. You can use Office 365 groups for anything from sharing files, discussing ideas, and planning events to working more efficiently and effectively.

How do I delete an Office 365 Group?

Log in to the Microsoft 365 Admin Center >> Expand “Teams & Groups” and click on Active Teams & Groups >> Select the Office 365 group to delete and click on the “Delete” button. You can also use the PowerShell script from Exchange Online, PnP PowerShell, and Azure AD to delete a group from Microsoft 365.
More info: Delete an Office 365 Group

How do I prevent users from creating groups in Office 365?

To disable the creation of Office 365 groups, You need to create a security group for users can create Microsoft 365 groups and then update the Azure Active Directory Setting to allow only the specified group.
More info: Lockdown Office 365 group creation

How do I add members to a group in Office 365?

Log in to Microsoft 365 Admin Center >> Click on “Active Teams & Groups” under “Teams & Groups” in the left navigation. Select the Office 365 group you wish to add a member(s) >> Click on the “Members” tab and select Members and then click on “Add members” >> Search and select members to add, and click on the “Add” button at the bottom. You can also add members to Microsoft 365 group using PowerShell.
More info: Add members to Office 365 Group

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *