PnP PowerShell: 3 Ways to Create Microsoft Teams with Custom Naming Conventions
Introduction
There are multiple ways to create Microsoft Teams using PnP PowerShell, each offering different levels of control over naming conventions. This post explores 3 distinct methods and compares their capabilities for customizing Site Title, Site URL, and M365 Group names.
When a Microsoft Team is created, a SharePoint site and M365 Group are automatically created in the backend. You may want to implement different naming conventions for each component:
Example Naming Strategy:
- Site Title:
Finance 2025 Team
(user-friendly display name) - Site URL:
finance2025
(clean, URL-friendly identifier) - M365 Group:
m365-teams-finance2025
(organizational prefix for easy identification)
Having a structured naming convention for M365 Groups makes it easier to recognise their purpose and differentiate them from other M365 Groups created for different services (Viva Engage, Planner, etc.).
⚠️ Important: Display Name Synchronization
Critical Note: The Site Title, Teams Display Name, and M365 Group Display Name are interconnected and automatically synchronized across all three platforms. When you update any of these display names, it affects all related components:
Display Name Updates Affect All Components
Method 1: Update via M365 Group (Fastest Synchronization)
# Updating M365 Group Display Name propagates to Teams and SharePoint relatively quickly
Set-PnPMicrosoft365Group -Identity "d1198df5-c4fe-4aa0-99fa-d8cf41f70977" -DisplayName "M365 Teams PRA"
Result: Changes to the M365 Group display name update both the Teams display name and SharePoint site title within minutes.
Output of updating the M365 Group Display Name:
Method 2: Update via Teams (Partial Immediate Sync)
# Updating Teams Display Name updates M365 Group instantly, SharePoint may take longer or not
Set-PnPTeamsTeam -Identity "d1198df5-c4fe-4aa0-99fa-d8cf41f70977" -DisplayName "Actuary Teams"
Result: M365 Group name updates immediately, but SharePoint site title may take 15-30 minutes to synchronize.
Output of updating the Teams Display Name:
Note: If SharePoint site title doesn’t update automatically, manually run Set-PnPTenantSite
to force synchronization.
Method 3: Update via SharePoint Site (Slowest Synchronization)
# Updating SharePoint Site Title propagates to M365 Group and Teams with some delay or not
Set-PnPTenantSite -Identity "https://contoso.sharepoint.com/sites/teams-Actuary" -Title "Actuary Teams Site"
Result: SharePoint site title updates immediately, but M365 Group and Teams display name may take 30-60 minutes to synchronize.
Output of updating the SharePoint Site Title:
Note: If M365 Group and Teams names don’t update automatically, manually run Set-PnPMicrosoft365Group
to force synchronization.
Impact of Display Name Changes:
- ✅ Teams: Team name updates in Teams interface
- ✅ SharePoint: Site title updates in SharePoint Online
- ✅ M365 Group: Group display name updates in admin centers
- ✅ Outlook: Group name updates in Outlook
Best Practice Recommendation
Choose your display names wisely during creation because changing them later affects the user experience across all Microsoft 365 services. Consider:
- User Recognition - Will users easily identify the team/site purpose?
- Professional Appearance - Does it maintain organizational standards?
- Consistency - Does it align with your naming conventions?
- Future-Proofing - Will the name remain relevant over time?
Method 1: New-PnPTeamsTeam
The most direct approach for creating Teams with basic naming control. Refer to New-PnPTeamsTeam for more info.
New-PnPTeamsTeam -DisplayName "Finance Team" -MailNickName "m365-Teams-Finance"
Key Features:
- ✅ Simple and straightforward
- ✅ Direct Teams creation
- ✅ Can set Teams properties like AllowCreateUpdateRemoveTabs , AllowUserDeleteMessages, etc..
- ❌ Limited naming flexibility
- ❌ Both Site URL and M365 Group are automatically derived from MailNickName
Output
Method 2: New-PnPMicrosoft365Group
Creates an M365 Group first, then converts it to a Team. Refer to New-PnPMicrosoft365Group for more info.
$m365Group = New-PnPMicrosoft365Group -DisplayName "PRA Team" -MailNickname "m365-Teams-PRA" -Description "Team for PRA operations" -CreateTeam
Key Features:
- ✅ Good control over M365 Group naming
- ✅ Single command with -CreateTeam flag
- ✅ Can add description during creation
- ✅ Can set M365 Group properties like HideFromOutlookClients, IsPrivate, etc
- ❌ Site URL still derived from MailNickname
Output
Method 3: New-PnPSite (Maximum Control)
The most flexible approach offering complete control over all naming aspects.
Connect-PnPOnline -Url "https://contoso.sharepoint.com/"
# Define naming strategy
$siteTitle = "Law Team" # User-friendly display name
$siteUrl = "Law" # Clean URL identifier
$siteDescription = "Law Team Site" # Site description
$groupName = "m365-teams-$siteUrl" # Structured group name
# Create Team Site with custom naming
New-PnPSite -Type TeamSite -Title $siteTitle -Alias $groupName -SiteAlias $siteUrl -Description $siteDescription -Wait
# Get the created M365 Group
$M365Group = Get-PnPMicrosoft365Group -Identity $groupName
# Convert to Teams
New-PnPTeamsTeam -GroupId $M365Group.Id
Write-Host "Team '$siteTitle' with M365 Group '$groupName' created successfully."
Key Features:
- ✅ Complete naming control
- ✅ Separate Site Title, URL, and Group name
- ✅ Follows naming conventions
- ✅ Most flexible approach
- ❌ More complex, multi-step process
Output
Naming Convention Best Practices
M365 Group Naming Strategy
Consider using prefixes to categorize your M365 Groups:
# Teams
"m365-teams-finance"
"m365-teams-hr"
# Viva Engage Communities
"m365-engage-companywide"
"m365-engage-innovation"
# Planner-only Groups
"m365-planner-projectalpha"
"m365-planner-events"
Benefits of Structured Naming:
- Easy Identification - Quickly recognize the purpose and type
- Better Organization - Group similar resources together
- Simplified Management - Easier to apply policies and governance
- Improved Search - More discoverable in admin centers
Method Comparison Table
Feature | New-PnPTeamsTeam | New-PnPMicrosoft365Group | New-PnPSite |
---|---|---|---|
Site URL Control | ❌ Auto-derived | ❌ Auto-derived | ✅ Fully Customizable |
M365 Group Name Control | ✅ Via MailNickName | ✅ Via MailNickname | ✅ Via Alias |
Complexity | 🟢 Simple | 🟡 Medium | 🔴 Complex |
Steps Required | 1 | 1 | 3 |
Naming Flexibility | 🔴 Limited | 🟡 Medium | 🟢 Maximum |
Best For | Quick team creation | Standard teams with descriptions | Enterprise naming standards |
Site Description | ❌ Not available | ✅ Available | ✅ Available |
Advanced Example: Bulk Team Creation
Here’s how to use Method 3 for creating multiple teams with consistent naming:
$teams = @(
@{ Title = "Finance Q1 Planning Teams"; Url = "financeq1"; Group = "m365-teams-financeq1" },
@{ Title = "HR Recruitment Teams"; Url = "hrrecruitment"; Group = "m365-teams-hrrecruitment" },
@{ Title = "IT Security Operations Teams"; Url = "itsecurity"; Group = "m365-teams-itsecurity" }
)
foreach ($team in $teams) {
try {
New-PnPSite -Type TeamSite -Title $team.Title -Alias $team.Group -SiteAlias $team.Url -Wait
$M365Group = Get-PnPMicrosoft365Group -Identity $team.Group
New-PnPTeamsTeam -GroupId $M365Group.Id
Write-Host "✅ Created: $($team.Title)" -ForegroundColor Green
}
catch {
Write-Host "❌ Failed: $($team.Title) - $($_.Exception.Message)" -ForegroundColor Red
}
}
Output
Conclusion
The choice between these three methods depends on your organization’s naming requirements and governance policies. For enterprise environments where different Site Titles, URLs, and M365 Group names are essential, Method 3 (New-PnPSite) provides the most flexibility and control.
Important Consideration: Carefully plan your display names during creation, as they will be synchronized across Microsoft Teams, SharePoint sites, and Microsoft 365 Groups, affecting the user experience across all platforms.
Key Takeaways:
- ✅ Method 3 offers complete naming control
- ✅ Structured naming improves organization and governance
- ✅ Consider your naming strategy before implementation
Which method do you prefer for your Microsoft Teams creation workflow? Share your naming convention strategies in the comments!