amateur
amateur

Reputation: 44605

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.

Upvotes: 1

Views: 2287

Answers (3)

alastairtree
alastairtree

Reputation: 4279

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

Upvotes: 1

deadlydog
deadlydog

Reputation: 24374

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.

Upvotes: 3

Zach Bonham
Zach Bonham

Reputation: 6817

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

Take a look at the available cmdlets.

Upvotes: 0

Related Questions