Reputation: 1062875
edit: IIS6; I'm not sure IIS7 is an option in the immediate future...
From a developer angle, I am constantly changing my IIS settings, or need to merge settings from other teams into different VMs. The "Save Configuration to Disk" has never really worked well for me.
Because we are making lots of small changes, web installation projects have never really worked either... Tools aimed for the web-admin aren't necessarily a good fit for the developer - we have different aims and needs.
Does anyone have a script / tool / utility that would allow us to quickly configure IIS? In particular:
from some find of flat input list (any format would do).
Upvotes: 12
Views: 1623
Reputation: 1644
may or may not help but check out http://rprieto.github.com/psDeploy/iis-6-cmdlets.html
Upvotes: 1
Reputation: 41
I'm a bit late to the show but I thought this PowerShell script my be useful, be aware I only use this for my local development box so apologies for the magic numbers.
AuthFlags = 4 is integrated authorisation
It doesn't exactly fulfil Marc's requirements but it's a good start.
If you download WMI Tools you can use them to explore the WMI interface to the IIS metabase.
function CreateAppPool($poolName,$userName,$password)
{
[wmiclass] $appPoolSettings = "root\MicrosoftIISv2:IISApplicationPoolSetting";
$newPool = $appPoolSettings.CreateInstance();
$newPool.Name = "W3SVC/AppPools/" + $poolName;
$newPool.WAMUsername = $userName;
$newPool.WAMUserPass = $password;
$newPool.AppPoolIdentityType = 3;
$newPool.Put();
# Do it again if it fails as there is a bug with Powershell/WMI
if (!$?)
{
$newPool.Put();
}
}
function CreateWebsite($webSiteName, $path, $port, $appPoolName)
{
[wmiclass] $bindingClass = 'root\MicrosoftIISv2:ServerBinding';
$bindings = $bindingClass.CreateInstance();
$bindings.Port = $port;
$webService = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebService";
$webSite = $webService.CreateNewSite($webSiteName, $bindings, $path);
[int] $index = $webSite.ReturnValue.IndexOf("'") + 1;
[int] $length = $webSite.ReturnValue.Length - $index - 1;
[string] $websiteID = $webSite.ReturnValue.SubString($index, $length) + "/root";
$webVirtualDirSetting = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebVirtualDirSetting" | Where-Object {$_.Name -eq $websiteID};
$webVirtualDirSetting.AppFriendlyName = $webSiteName;
$webVirtualDirSetting.AppPoolId = $appPoolName;
$webVirtualDirSetting.AccessFlags = 517;
$webVirtualDirSetting.AuthFlags = 4;
$webVirtualDirSetting.Put();
#Switch the Website to .NET 2.0
C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -sn W3SVC/
}
$webSiteName = "MyWebsiteName";
$webSitePath = "C:\MyWebsitePath";
$webSitePort = "9001";
$appPoolName = "MyWebsitePool";
$appPoolIdentity = "MYDESKTOP\MyWebsiteIdentity";
$appPoolPassword = "MyWebsitePassword";
CreateAppPool $appPoolName $appPoolIdentity $appPoolPassword
CreateWebsite $webSiteName $webSitePath $webSitePort $appPoolName
Upvotes: 4
Reputation: 3340
I can think of three options off the top of my head...
I think if it was me needing to do this, I would use Powershell, or remove the need all together and create a base VM install that had all the basics already configured in. When I'm done with teasting I'd just rollback the harddrive and be free to go again.
Upvotes: 11
Reputation: 893
You may want to look into the Metabase XML config files for IIS and allowing direct edit.
Upvotes: 1
Reputation: 15673
Powershell would work. If you wanted to avoid dependencies, you could also generate a script to run against AdsUtil.vbs.
Probably easier would be standardizing on IIS7 where all this stuff lives in web.config files making life alot easier.
Upvotes: 1