8

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...

3
  • The new cmdlets should be easier to use learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/… Commented Nov 28, 2019 at 0: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? Commented Nov 28, 2019 at 12:10
  • That's because the physical path is a property under virtual directory, learn.microsoft.com/en-us/iis/get-started/… Open applicationHost.config and you should soon learn it. Commented Nov 28, 2019 at 13:32

1 Answer 1

14

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.