Using Powershell to create a web application in a folder that is not an application

前端 未结 3 1216
情深已故
情深已故 2021-02-09 16:30

I want to create a web application in IIS that does not live at the root of the IIS site.

i.e. MySite/beta/WebApplication.

This is my starting point:

3条回答
  •  一整个雨季
    2021-02-09 17:04

    Since you are using the same physical file repository that is used by the "MySite" collection, it will create the "beta" folder. If you place this new web application in its own path (i.e., "C:\Sites\WebApps\WebApplication") you will get the desired results. The code below worked for me.

    New-WebApplication "TestingViaPosh" -Site "Default Web Site" -ApplicationPool "DefaultAppPool" -
    PhysicalPath "C:\Users\MyUserId\Documents\TestWebApp"
    

    EDIT: To create a web application in a folder underneath the root of a website, you need to first create the folder in the site you desire (i.e., "C:\Sites\MySite\Beta"). Then the Powershell command will look like this:

    New-WebApplication "TestingViaPosh" -Site "Default Web Site\Beta" -ApplicationPool "DefaultAppPool" -PhysicalPath "C:\Users\MyUserId\Documents\TestWebApp"
    

提交回复
热议问题