How to Change a SharePoint Site URL Using PnP PowerShell?

One of my clients recently asked me to change the SharePoint site URL. In this tutorial, I will show you how to change a SharePoint site address or URL using PnP PowerShell.

If you are new to PnP PowerShell and If you haven’t installed it yet, you can do so using the command.

Install-Module -Name PnP.PowerShell

Change SharePoint site URL using PnP PowerShell

In PnP PowerShell, we can use the Rename-PnPTenantSite cmdlet is used to start the rename process. Here is the complete script:

Connect-PnPOnline -Url https://szg52-adnub.sharepoint.com -Interactive
# Define variables
$OldSiteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
$NewSiteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQsNew"

# Start the rename process
Rename-PnPTenantSite -Identity $OldSiteUrl -NewSiteUrl $NewSiteUrl

Here:

  • $OldSiteUrl: The current URL of the site you want to rename.
  • $NewSiteUrl: The new URL you want to assign to the site.

Once you execute the above script, you can see the output in the screenshot below:

Change SharePoint site URL using PnP PowerShell

The rename process can take some time, depending on the size of the site and the content within it. You can check the status of the rename operation using the following command:

Get-PnPTenantSite -Url $NewSiteUrl

This will return the details of the site, including its current URL and status.

Conclusion

In this tutorial, I have explained how to change the SharePoint site URL or address using PnP PowerShell. With an example, I have explained how it works with the complete script.

You may like the following tutorials:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.