Create or Delete Managed Path in SharePoint using PowerShell

Managed paths in SharePoint enables us to create a uniform navigational structure to group multiple site collections together. SharePoint Managed Paths can be defined using PowerShell or STSADM command-line tool. Managed paths are explained in my other article: Managed path in SharePoint

Create Managed Path in SharePoint using PowerShell:

Use New-SPManagedPath cmdlet to create a new managed path in a web application on the SharePoint farm.

New-SPManagedPath -WebApplication "" -RelativeURL "teams"

This adds a managed path in SharePoint 2013 using PowerShell. By default, the managed path is created as a wildcard inclusion type. You can include the Explicit switch to create a managed path of explicit inclusion type.

New-SPManagedPath -WebApplication "" -RelativeURL "/departments/" -Explicit
Create/Delete/Get Managed Paths in SharePoint PowerShell

PowerShell to Delete Managed path in SharePoint:
If you need to delete a managed path from a specific web application: use Remove-SPManagedPath cmdlet.

Remove-SPManagedPath -Identity "Teams" -WebApplication ""

Technet Reference for configuring managed paths:

Check whether a Particular Managed Path Exists:
PowerShell offers one more cmdlet: Get-SPManagedPath to check the existence of a managed path. Say, for e.g. you may want to check whether a particular managed path exists or not before creating a managed path.

Get Existing Managed Paths

Get-SPManagedPath -WebApplication "" 

Get-SPManagedPath displays all managed paths for the given web application. Let’s check if the managed path exists before creating a new managed path:

Create a managed path in SharePoint using PowerShell

Let’s add a managed path in SharePoint 2013 with PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

 write-host "Enter the Web Application URL:"
 write-host "Enter the Managed Path:" 
 $ManagedPath =read-host

 #Check whether the particular managed path exist already
 $ManagedPathExists = Get-SPManagedPath -WebApplication $WebAppURL -Identity $ManagedPath -ErrorAction SilentlyContinue

 if ($ManagedPathExists -eq $null)
    #Go ahead and create the managed path
    New-SPManagedPath -RelativeURL $ManagedPath -WebApplication $WebAppURL
    Write-Host "Managed path $ManagedPath already exists!"
Managed paths created in the Central Admin site can be used only in path-based site collections! Not on host-named site collections (HNSC).

Using STSADM Tool to Add/Remove Managed Path:

These two stsadm command line tool switches available to Add/Remove Managed paths in SharePoint.

  • Stsadm -o AddPath
  • Stsadm -o DeletePath

stsadm -o addpath -url <managed path URL followed by web app URL> -type <explicitinclusion or wildcardinclusion>
stsadm -o addpath -url -type wildcardinclusion

Delete managed path in SharePoint using STSADM:

stsadm -o deletepath -url <Managed Path URL with Web App>
stsadm -o deletepath -url

Tail: What if I delete the Managed path in use?
Answer: Your SharePoint Sites under the specific managed path will result: HTTP 404 Page Not Found! Refer my post: SharePoint Managed Paths – FAQs – If you have any questions on SharePoint Managed paths!

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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