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:
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.
Within 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 which can be obtained from Microsoft:
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.
Author
Alan is a passionate advocate for enhancing organisational productivity, security, and compliance. With extensive experience in crafting solutions around Microsoft's suite of products, including Microsoft 365, Power Platform, and Dynamics 365, he has consistently demonstrated the transformative potential of these technologies.
In his role as a Cross-functional Technical Architect at the Microsoft Technology Centre for over six years, Alan excels at helping organisations harness the full scope of Microsoft technologies. He specialises in guiding them towards realising the manifold benefits that these tools can provide at individual, team, and organisational levels. Alan's expertise is pivotal in propelling businesses to new heights through the effective utilisation of technology.