Move SharePoint Web Application’s IIS Physical Path to a New Location

Requirement: Move SharePoint web application’s IIS physical location from system drive (c:\) to application drive (d:\) due to new server support policies!


SharePoint web applications, by default placed under: “C:\inetpub\wwwroot\wss\VirtualDirectories” when we create them. There is no UI/direct way to change the physical location of SharePoint IIS web sites later. However, these three steps can be utilized to move the SharePoint web application’s IIS physical directory to a new location:

  1. Copy all contents from the current virtual directory to new directory
  2. Change IIS website’s physical path
  3. Update SharePoint web application to point to the new directory path.

Let’s automate these manual steps with PowerShell.

PowerShell Script to Move IIS Website to New Physical Location:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Import IIS Module
Import-Module WebAdministration

$IISSiteName = "Crescent Intranet" 
#Get Web Applications' IIS Settings
$WebApp = Get-SPWebApplication $WebAppURL
$IISSettings = $WebApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::Default]
$OldPath = $IISSettings.Path

#Check if destination folder exists already. If not, create the folder
if (!(Test-Path -path $NewPath))        
    $DestFolder = New-Item $NewPath -type directory          

#***** Step 1 - Copy Current Virutal Directory to new location **** #
Copy-Item -Path $OldPath\* -Destination $NewPath -Force -Recurse 

#***** Step 2 - Change IIS Web Site's Physical path ******
Set-ItemProperty "IIS:\Sites\$($IISSiteName)" -name PhysicalPath -value $NewPath

#***** Step 3 - Update SharePoint Web Application ******
#Change the Web App path
$IISSettings.Path = $NewPath
#Update Web Application

Please note, You’ll have to repeat steps 1 and 2 in all SharePoint web front-end servers.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

One thought on “Move SharePoint Web Application’s IIS Physical Path to a New Location

  • An absolute life saver when moving Central Admin off the system drive. Works like a champ.


Leave a Reply

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