New-MgGroup

What is New-MgGroup?

The New-MgGroup cmdlet in Microsoft Graph PowerShell is used to create new groups in Microsoft 365, including Office 365 Groups (Unified Groups), Security Groups, and Mail-enabled Security Groups. It allows administrators to configure key group properties at creation, such as display name, mail nickname, group type, and security settings.


Why Use New-MgGroup?

Using New-MgGroup streamlines group creation and management by enabling automation through PowerShell scripts.

Automation Benefits:

  • Time Savings – Create multiple groups in bulk without manually configuring them in the Microsoft 365 admin center.
  • Consistency – Apply standard naming conventions and configurations to all groups.
  • Integration –Embed group creation into larger provisioning workflows for users and teams.
  • Scalability –Efficiently handle high-volume group creation for departments, projects, or entire organizations.

Prerequisites

Before using New-MgGroup, ensure you have the Microsoft Graph PowerShell module installed and the necessary permissions granted.

Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Group.ReadWrite.All"

How to Use New-MgGroup?

Syntax

New-MgGroup -DisplayName <String> -MailNickname <String> -GroupTypes <String[]> -MailEnabled <Boolean> -SecurityEnabled <Boolean>

This cmdlet can be used to create different types of groups in Microsoft 365 by adjusting the GroupTypes, MailEnabled, and SecurityEnabled parameters.


New-MgGroup Examples

  1. Create an Office 365 Group (Unified Group)
  2. New-MgGroup -DisplayName "Office 365 Group 1" -MailNickname "O365Group1" -GroupTypes "Unified" -MailEnabled:$true -SecurityEnabled:$false
  3. Create a Security Group
  4. New-MgGroup -DisplayName "Security Group 1" -MailNickname "SecGroup1" -SecurityEnabled -MailEnabled:$false
  5. Create Multiple Office 365 Groups by Reading Data from a CSV File
  6. CSV File Example

    DisplayName,MailNickname,Description
    HR Team 1000,HRTeam1000,Group for HR 1000 department
    Sales Team 1000,SalesTeam1000,Group for Sales 1000 department
    IT Team 1000,ITTeam1000,Group for IT 1000 department

    PowerShell Script

    $groups = Import-Csv -Path "C:\Path\To\Groups.csv"
    foreach ($group in $groups) {
        $groupParams = @{
            DisplayName     = $group.DisplayName
            MailNickname    = $group.MailNickname
            Description     = $group.Description
            GroupTypes      = @("Unified")
            MailEnabled     = $true
            SecurityEnabled = $false
        }
    New-MgGroup -BodyParameter $groupParams
    }
                                                

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex