Rename a Microsoft Team and the associated SharePoint site
There are many situations where a Teams site and the underlying SharePoint site may need to be renamed:
- Created in error
- Organisational restructure
- Introduction of naming policies
This has been a challenging goal to achieve but it is now relatively straightforward when you combine the SharePoint and Teams PowerShell commandlets.
Objective
Starting with a SharePoint site and Team that are set up with multiple channels and associated content, we want to change the following elements:
Element | Original value | New value |
---|---|---|
Site Name | ToBeRenamed | NewlyNamed |
Site Title | To Be Renamed | Newly Named |
Url | https://[tenant].sharepoint.com/sites/ToBeRenamed | https://[tenant].sharepoint.com/sites/NewlyNamed |
There are several checks that need to be proven to work once the rename is complete:
- Files are still visible in the channels
- “Open in SharePoint” links still work in the files tab and from the ellipsis in the channel
- OneNote tabs still work
- Planner tabs still work
Original Team Configuration
The SharePoint site is a default Team site created within Sites.
With in Teams, the following channels exist
- General
- Files has a file in it called “SharePoint.docx”
- Wiki has two pages
- OneNote is using the default notebook and has a section called “General”
- Planner has a plan called “ToBeRenamed”
- Channel A
- Files has a file in it called “Farm A.docx”
- Wiki has two pages
- OneNote is using the default notebook and has a section called “Channel A”
- Planner has a plan called “ToBeRenamed - Channel A”
- Channel B
- Files has a file in it called “Farm B.docx”
- Wiki has two pages
- OneNote is using the default notebook and has a section called “Channel B”
- Planner has a plan called “ToBeRenamed - Channel B”
Renaming the Team and SharePoint Site
There are two PowerShell libraries that are needed:
- SharePoint Online - https://docs.microsoft.com/en-us/powershell/sharepoint/?view=sharepoint-ps
- Microsoft Teams - https://docs.microsoft.com/en-us/powershell/teams/?view=teams-ps
The latter is in development and is using the beta versions of Microsoft Graph to manage Microsoft Teams.
The PowerShell to connect
## Connect to the services
Connect-SPOService -Url https://$orgName-admin.sharepoint.com
Connect-MicrosoftTeams
## Set the variables for the old site and the new values
$oldSiteName = "ToBeRenamed"
$oldSiteTitle = "ToBeRenamed"
$oldSiteUrl = "https://$orgName.sharepoint.com/sites/$oldSiteName"
$newSiteName = "NewlyNamed"
$newSiteTitle = "Newly Named"
$newSiteUrl = "https://$orgName.sharepoint.com/sites/$newSiteName"
## Rename the SharePoint site
Start-SPOSiteRename `
-Identity $oldSiteUrl `
-NewSiteUrl $newSiteUrl `
-NewSiteTitle $newSiteTitle
## Get the Team so the GroupId can be referenced
$team = Get-Team -DisplayName $oldSiteTitle
## Rename the Team
Set-Team `
-GroupId $team.GroupId `
-DisplayName $newSiteTitle `
-MailNickname $newSiteName
Outcome
The URL of the SharePoint site will now be renamed and name of the Team will be renamed.
There are however several elements that retain their original names:
OneNote notebook
The OneNote notebook will retain the same name.
When creating a new tab for OneNote, the existing notebook will not be tagged as the default notebook
The notebook can be renamed but it will no longer show up as the “Default team notebook”. Once the notebook is renamed, the links in the tabs will still work without having to be updated.
Planner plans
The names of the plans will not be updated so if they referenced the name of the Team, then they will still have the old names:
The good news is that if the Plan is renamed, the links in the channel tabs will still work as they do not use the name of the plan in the link.