5

When creating a site I manage to set the path with the following line of code

New-WebSite -Name "mysite" -port 8084 -PhysicalPath "c:\inetpub\wwwroot" -ApplicationPool "myappPool"

I have tried to figure out how to update the path, nothing found via Configuration Editor. I thought I had it with the following command

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.applicationHost/sites/site[@name='mysite']/virtualDirectoryDefaults" -name "physicalPath" -value "c:\inetpub\wwwroot\mysite"

...but, it is not virtualdirectory I want to update, but the actual site...

rhellem
  • 769
  • 1
  • 11
  • 26
  • The new cmdlets should be easier to use https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/iisadministration-powershell-cmdlets – Lex Li Nov 28 '19 at 00:29
  • But still not able to see the physicalPath PS C:\> $Site = Get-IISSite "Default Web Site" PS C:\> $Site.Attributes Where could it be? – rhellem Nov 28 '19 at 12:10
  • That's because the physical path is a property under virtual directory, https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis Open applicationHost.config and you should soon learn it. – Lex Li Nov 28 '19 at 13:32

1 Answers1

10

You could use below PowerShell command to change the iis site physical path.

run PowerShell as administrator.

run below command:

PS C:\WINDOWS\system32> Import-Module WebAdministration
PS C:\WINDOWS\system32>  Set-ItemProperty IIS:\Sites\sitea -name physicalPath -value "D:\s1"

after changing the path open iis manager and refresh the site.

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26