Rename a Microsoft Team and the associated SharePoint site

23 Nov 2019 3-minute read Al Eardley
Microsoft 365PowerShell
Micrsoft Teams

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:

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.

Screenshot of Teasm with the name of the Team highlighted

There are however several elements that retain their original names:

OneNote notebook

The OneNote notebook will retain the same name.

Screenshot of OneNote showing the name of the notebook

When creating a new tab for OneNote, the existing notebook will not be tagged as the default notebook

Screenshot of the dialogue for adding a OneNote tab with a notebook flagged as default

Screenshot of the dialogue for adding a OneNote tab without a notebook flagged as default

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:

Screenshot of Planner showing the old Team name

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.

Comment on this post: