简体   繁体   中英

create site in IIS with powershell

Working with an mvc4 application that runs in IIS 7.5, the site though exist once on disk, has over a 100 url's pointing to it. This is because the site displays content based on the country that needs to access it.

Due to this, the site can have over a 100 bindings, which is very hard to manage.

I am looking to automate the creating of the site in IIS using powershell. I would run this during each deployment to ensure each of my environments are identical (dev, qa, production).

The powershell script would delete the site and recreate it, applying bindings, configuring it etc. I am a newbie to powershell so I would appreciate any help with this.

You should be able to use the PowerShell IIS Administrative Cmdlets . I show how to automate creating and deleting web applications using them on my blog that should get you started.

I have a script I use when creating a website and AppPool in IIS 7+ (under .net4, Integrated pipeline, etc) and thought you might find it useful as its a bit simpler than some of the other answers. It will delete the site and replace it if it already exists making it good in continuous integration scenarios.

Use it as so:

CreateSite.ps1 [WebsiteName] [AppPoolName] [Port] [Path]

If you are reinstalling the site, you will need to stop it first. That is done as so:

StopSite.ps1 [WebsiteName] [AppPoolName]

you gan grab the scripts from my gist

There is an IIS provider for PowerShell which you can use to manage IIS from PowerShell.

Take a look at the available cmdlets .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM