SharePoint 2013 – Changing the name of a Web Application

2017-12-11T10:04:35+00:00 April 26th, 2013|PowerShell, Sharepoint|

Let us assume that you have a SharePoint 2013 environment with a Web Application called “Intranet” but it should be called “Intranet – 80”. What do you do? Many posts would have you believe you need to remove and re-create the Web Application and re-attach the old Content Database. I don’t see the point, it requires several components which I always try to avoid; downtime, SQL access (or working alongside your DBA) and extra effort if the existing configuration isn’t documented. What’s a quicker and better way? PowerShell, of course! 🙂

Ok, so it’s not that likely that you would need to rename a Web Application unless you are either a) re-organising your entire naming convention or b) someone created a Web Application without complying to said naming convention. All you need is the following:

  • Access to the Management Shell (don’t forget to open with elevated privileges)
  • The existing Web Application name
  • The desired Web Application name

From your PowerShell session simply execute the following cmdlet – remembering to substitute OldWebAppName and NewWebAppName accordingly:

$WebApp = SPWebApplication | where {$_.Name -match "OldWebAppName"}
$WebApp.Name ="NewWebAppName"
# This bit is just to verify it updated correctly
Get-SPWebApplication | where {$_.Name -match "NewWebAppName"}

It goes without saying that the IIS site name will need changing on all your WFE servers, so don’t forget to do that too.

Final note, although this will work fine with SharePoint 2010 I haven’t tested it, so the usual “without warranty” statement applies.