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!
Solution:
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 SharePoint web application's IIS physical directory to a new location:
PowerShell Script to Move IIS Web Site to New Physical Location:
Solution:
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 SharePoint web application's IIS physical directory to a new location:
- Copy all contents from the current virtual directory to new directory
- Change IIS website's physical path
- Update SharePoint web application to point to the new directory path.
PowerShell Script to Move IIS Web Site to New Physical Location:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Import IIS Module Import-Module WebAdministration #Variables $WebAppURL="http://intranet.crescent.com/" $NewPath="D:\IIS\VirtualDirectories\Intranet.Crescent.com" $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 $WebApp.Update()Please note, You'll have to repeat steps 1 and 2 in all SharePoint web front end servers.
An absolute life saver when moving Central Admin off the system drive. Works like a champ.
ReplyDelete