What Are Microsoft 365 Groups?
Microsoft 365 Groups are a cross-application membership service. They bring together people, information, and resources, providing access to shared tools like:
- Outlook: For shared mailboxes and calendars.
- Teams: For real-time communication and collaboration.
- SharePoint: For document management and sharing.
- Planner: For task management.
A Microsoft 365 Group automatically provisions these resources, making it easier for teams to collaborate without the need for additional setup.
Why Use New-MgGroup?
The New-MgGroup cmdlet allows administrators to:
- Automate group creation processes for consistency and efficiency.
- Create multiple groups in bulk, saving time.
- Assign specific attributes, such as mail nicknames and security settings, during group creation.
By using New-MgGroup, you can streamline workflows and reduce the chances of errors associated with manual group creation.
Setting Up Microsoft Graph PowerShell
To use New-MgGroup, you’ll need to install and configure the Microsoft Graph PowerShell module:
- Install Microsoft Graph PowerShell: Install the module with the following command:
Install-Module Microsoft.Graph -Scope CurrentUser - Connect to Microsoft Graph: Connect to your Microsoft 365 tenant with the required permissions:
Connect-MgGraph -Scopes "Group.ReadWrite.All" - Disconnect After Use: Disconnect your session when tasks are complete:
Disconnect-MgGraph
You will be prompted to log in with your admin credentials.
Practical Examples of New-MgGroup
Create a Single Group
To create a single Microsoft 365 group with basic attributes:
New-MgGroup -DisplayName "test8811" -MailNickname "test8811" -GroupTypes "Unified" -MailEnabled:$false -SecurityEnabled:$false
This creates a Microsoft 365 group named “test8811” with email functionality enabled.
Create Multiple Groups
To create multiple groups in one script, define their details in an array and iterate through it:
$groups = @(
@{ DisplayName="HR Team 1220"; MailNickname="hrteam1220"; },
@{ DisplayName="Sales Team 1220"; MailNickname="salesteam1220"; }
)
foreach ($group in $groups) {
New-MgGroup -DisplayName $group.DisplayName -MailNickname $group.MailNickname -MailEnabled:$true -GroupTypes @("Unified") -SecurityEnabled:$false
}
This script creates multiple groups programmatically.
Create Multiple Groups from a CSV File
For bulk group creation, import data from a CSV file.
$groups = Import-Csv -Path "C:\Groups.csv"
foreach ($group in $groups) {
New-MgGroup -DisplayName $group.DisplayName -MailNickname $group.MailNickname -MailEnabled:$true -GroupTypes @("Unified") -SecurityEnabled:$false
}
This script reads group details from the CSV file and creates them automatically.
Key Parameters & Configuration Options (Quick Reference)
Understanding key properties helps you create Teams more effectively.
| Parameter | Required | Purpose |
| DisplayName | Yes | Name of the Group |
| MailNickname | Yes | Email alias |
| MailEnabled/td> | Yes | Enables email functionality |
| SecurityEnabled | Yes | Determines security group behavior |
| GroupTypes | Optional | Defines type (Unified, DynamicMembership)/td> |
| Description | Optional | Group purpose |
| MembershipRule | Optional | Required for dynamic groups |
| Visibility | Optional | Public or Private group |
When Should You Use New-MgGroup?
Use the New-MgGroup cmdlet in the following scenarios:
- Bulk group provisioning for departments, roles, or projects
- Automating group creation workflows during onboarding
- Creating dynamic groups based on user attributes
- Standardizing naming conventions and configurations
New-MgGroup vs Admin Center
| Method | Best For | Limitation |
| New-MgGroup (PowerShell) | Bulk creation, automation | Requires scripting knowledge |
| Microsoft 365 Admin Center | Manual group creation | Not scalable |
| Entra Admin Center/td> | Advanced management | Limited automation |
Real-World Automation Scenarios
-
Department-Based Group Creation
- Automatically create groups for HR, Finance, IT
- Apply consistent naming conventions
-
Dynamic Group Provisioning
- Create groups based on rules (e.g., department, domain)
- Automatically update membership using MembershipRule
-
Bulk Group Creation via CSV
- Import group data and create multiple groups at once
- Ideal for large-scale deployments
-
Application & Access Control Groups
- Create security groups for resource access
- Use groups for role-based access control
Common Limitations & Considerations
Strengths
- Supports bulk and automated group creation
- Enables dynamic group membership
- Integrates with Microsoft Graph ecosystem
Limitations
- Requires correct permissions (Group.ReadWrite.All)
- Cannot create distribution lists via Graph PowerShell
- Owners/members often require separate cmdlets
Pro Tips for Using New-MgGroup
- Always define group type clearly (Unified vs Security)
- Use -BodyParameter for advanced configurations
- Validate mail nickname uniqueness
- Use dynamic rules carefully to avoid unintended memberships
- Combine with lifecycle scripts for full automation
Example: End-to-End Group Provisioning Workflow
A practical workflow could look like:
- Create group using New-MgGroup
- Add owners using New-MgGroupOwnerByRef
- Add members using New-MgGroupMember
- Assign licenses (if applicable)
- Integrate with Teams or SharePoint
Frequently Asked Questions
- What is New-MgGroup used for?
- What types of groups can I create with New-MgGroup?
- What permissions are required?
- Can I create multiple groups using New-MgGroup?
- Can I create distribution lists using New-MgGroup?
New-MgGroup is used to create Microsoft 365 groups using Graph PowerShell, enabling automation and bulk provisioning.
You can create Microsoft 365 (Unified) groups and security groups, including dynamic groups.
You need permissions such as Group.ReadWrite.All to create groups successfully.
Yes, you can import data from a CSV file and create multiple groups in bulk.
No, distribution lists are not supported via Graph PowerShell and require other tools
Advanced Tips for New-MgGroup Usage
- Set Additional Properties During Creation: Specify visibility and description:
New-MgGroup -DisplayName "Dev Team" -MailNickname "devteam" -MailEnabled:$true -GroupTypes @("Unified") -Visibility "Private" -Description "Development team working on internal projects"
$groupId = (New-MgGroup -DisplayName "Support Team" -MailNickname "supportteam" -MailEnabled:$true -GroupTypes @("Unified") -SecurityEnabled:$false).Id
New-MgGroupMember -GroupId $groupId -DirectoryObjectId "user-id"
New-MgGroup -DisplayName "Test Group" -MailNickname "testgroup" -MailEnabled:$true -GroupTypes @("Unified") -SecurityEnabled:$false -WhatIf
Conclusion
The New-MgGroup cmdlet is an invaluable tool for Microsoft 365 administrators, enabling efficient and automated group creation. By mastering New-MgGroup, you can enhance productivity, ensure consistency, and maintain better control over your Microsoft 365 environment.
By mastering New-MgGroup, you can enhance productivity, ensure consistency, and maintain better control over your Microsoft 365 environment. Start scripting today and take your group management to the next level!
🚀 Community Edition Released!
Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.
Get it on GitHub Know More