How To Remove a SharePoint Redirect Using PowerShell

Introduction

SharePoint redirects are created automatically every time a SharePoint Administrator renames an existing SharePoint site URL to something else. This means the redirect is created as a pointer to the new location. This helps avoid dead links from old messages, favorites etc..

Removing a SharePoint redirect can be necessary if for example the address is requested to be used by someone else for another site. Below is a step-by-step guide on how to remove a SharePoint redirect using PowerShell.

Prerequisites

Before proceeding, ensure you have:

  1. Administrative access to the SharePoint environment.
  2. The SharePoint Management Shell installed.
  3. Proper permissions to execute PowerShell commands and modify SharePoint settings.

Steps to Remove a SharePoint Redirect

Launch SharePoint Management Shell

Open the SharePoint Management Shell as an administrator. This shell is specifically designed for managing SharePoint and provides the necessary cmdlets.

Load the SharePoint PowerShell Module (if needed)

In some environments, you may need to load the SharePoint module manually. Use the following command:

Import-Module Microsoft.Online.SharePoint.PowerShell

Skip this step if you have it always loaded.

Connect to your SharePoint Admin Center

You will need to access your SharePoint Admin Center address, for this you will need to have at the minimum a SharePoint Administrator role assigned to the account you will use.

Connect-SPOService -Url https://<your tenant>-admin.sharepoint.com

Replace the tenant

Check what SharePoint Redirects exist in your tenant

SharePoint redirects have a special template assigned to them, which is: REDIRECTSITE#0. You can run the following command to check what redirects you already have:

Get-SPOSite -Template REDIRECTSITE#0

Unlock the SharePoint Site

You probably already know which redirect you need to remove from the output from the previous step. The next step is to unlock the site, because when the site address rename occurred, the process automatically locks the site.

Set-SPOSite -Identity “https://<your tenant>.sharepoint.com/sites/<your site>” -LockState “Unlock”

Replace your tenant and site

Remove the SharePoint Redirect

Now the redirect has been unlocked, we are free to remove the redirect completely from the tenant.

Remove-SPOSite -Identity “https://<your tenant>.sharepoint.com/sites/<your site>”

Replace your tenant and site

Final Confirmation

The redirect is now removed, and you can confirm it

Get-SPOSite -Template REDIRECTSITE#0

ADMIN
ADMIN

Leave a Reply

Your email address will not be published. Required fields are marked *