Tag Archives: iis

How i automate website creation with Powershell

If you, like me, create lots and lots of websites almost every day you probably noticed that a lot of the things you do are repetitive.

I have a lot of rules that almost all my websites follow.

  • I name the pool, the site and the folder the same (like site.domain.com)
  • I always add a binding following the pattern 17000 + site id, so a site with site id 13 has a binding for localhost:17013
  • I set idle time-out to 0
  • I add a scheduled recycle at 02:00 (for load balanced environments att set it at 03:00 for the other node)
  • I always create a scheduled job to take care of log rotation

To avoid making misstakes, and to make sure it gets done the same way every time, i use this Powershell. It’s not perfect, but it works for me, and it does exactly what i need it to.

In the end of the script, where the scheduled job is created, i use a little application called LogRotate which i may publish on the internet. In the mean time, you can use it as a way to add a scheduled task.

Maybe it will work for you as well, or maybe you can pick the parts you need. Enjoy!

 

How to create Websites (and more) with PowerShell?

If you, like me, are maintaining lots of websites, you probably want to script as much as you can. It’s time consuming to change a setting for 20+ websites, and it’s also a great chance you miss something in the process.

PowerShell is really neat in these cases, and it gets better for every new release as well.

This is a script i use to do the following:

  1. Create a new application pool, with the preferred .NET version, identity and a few other settings
  2. Create a folder to hold the website
  3. Create the website
  4. Configure a scheduled task to rotate and archive log files.

This script is highly customized for my needs and my environment. As you can se there’s a lot of assumptions in the script, that you may want to change, but i may be a nice start for you!