0
0
AzureHow-ToBeginner · 3 min read

How to Create a Group in Azure AD Quickly and Easily

To create a group in Azure AD, use the Azure Portal by navigating to Groups and clicking New group, then fill in the details and save. Alternatively, use the Azure PowerShell cmdlet New-AzureADGroup to create a group programmatically.
📐

Syntax

When creating a group in Azure AD using PowerShell, the main cmdlet is New-AzureADGroup. Here is the syntax:

  • -DisplayName: The name shown for the group.
  • -MailEnabled: Set to $false for security groups, $true for mail-enabled groups.
  • -MailNickname: A unique alias for the group email.
  • -SecurityEnabled: Set to $true for security groups.
  • -GroupTypes: Use "Unified" for Microsoft 365 groups, empty for security groups.
powershell
New-AzureADGroup -DisplayName "MyGroup" -MailEnabled $false -MailNickname "mygroup" -SecurityEnabled $true -GroupTypes @()
💻

Example

This example creates a security group named "Developers" in Azure AD using PowerShell. It is not mail-enabled and is security-enabled.

powershell
Connect-AzureAD
New-AzureADGroup -DisplayName "Developers" -MailEnabled $false -MailNickname "developers" -SecurityEnabled $true -GroupTypes @()
Output
ObjectId DisplayName Description -------- ----------- ----------- 12345678-90ab-cdef-1234-567890abcdef Developers
⚠️

Common Pitfalls

  • Forgetting to connect to Azure AD with Connect-AzureAD before running group commands.
  • Using -MailEnabled $true without specifying a valid -MailNickname causes errors.
  • Trying to create Microsoft 365 groups without specifying -GroupTypes "Unified".
  • Using duplicate -MailNickname values leads to conflicts.
powershell
## Wrong: Missing Connect-AzureAD
New-AzureADGroup -DisplayName "TestGroup" -MailEnabled $false -MailNickname "testgroup" -SecurityEnabled $true -GroupTypes @()

## Right: Connect first
Connect-AzureAD
New-AzureADGroup -DisplayName "TestGroup" -MailEnabled $false -MailNickname "testgroup" -SecurityEnabled $true -GroupTypes @()
📊

Quick Reference

ParameterDescriptionExample Value
-DisplayNameName of the group"MarketingTeam"
-MailEnabledEnable email for group$false for security groups
-MailNicknameUnique email alias"marketingteam"
-SecurityEnabledEnable security features$true for security groups
-GroupTypesType of group"Unified" for Microsoft 365 groups

Key Takeaways

Use Azure Portal or PowerShell to create groups in Azure AD easily.
Always run Connect-AzureAD before creating groups with PowerShell.
Set MailEnabled and GroupTypes correctly based on group type.
MailNickname must be unique and valid to avoid errors.
Microsoft 365 groups require GroupTypes set to "Unified".