Rename an IIS Web Application with PowerShell

Want to rename an IIS Web Application on a Windows 2008 R2 server? It’s not possible from the GUI, but it’s simple to accomplish using PowerShell. First, let’s create a web application in an existing website and then verify it exists:

Import-Module WebAdministration
New-Item -ItemType Directory -Path d:\iis\robbinsapps
New-WebApplication -Name RobbinsApps -Site MikeFRobbins -PhysicalPath d:\iis\robbinsapps -ApplicationPool "ASP.NET v4.0"
Get-ChildItem iis:\sites\mikefrobbins

ren-webapp1.png

Here it is in the GUI:

ren-webapp2.png

Rename the web application using PowerShell and then verify it was renamed:

Rename-Item 'IIS:\Sites\MikeFRobbins\RobbinsApps' 'RobbinsApps-Archive'
Get-ChildItem iis:\sites\mikefrobbins

ren-webapp3.png

Here it is again in the GUI showing that it has indeed been renamed:

ren-webapp4.png

ยต