Question : Powershell and IIS configuration

I'm a bit new to Powershell. I am looking for the ability configure an IIS6 website. More specifically I want to insert an Application Extension Mapping.

For an idea of what I'm trying to do...
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
Look for the section at the end called "IIS Configuration: using RewriteModule with extensions other than .aspx ".

Thanks in advance.

Answer : Powershell and IIS configuration


Good morning,

Unless you have a particular reason to need to use WMI I recommend dropping it in favour of ADSI. ADSI is very easy to work with for IIS, where using WMI will introduce a need to create an manipulate a lot of extra objects. The parts we're concerned with are treated as string arrays in ADSI.

A very basic sample of the ADSI method is below.

The example connects to the Default Web Site (ID = 1). We can loop through all sites or attach to a specific site. Whatever happens it must be with the Site ID, connecting to a specific site by anything but that requires a loop through all sites until the required ID is located.

Chris

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
$Site = [ADSI]"IIS://./W3SVC/1/Root"
$ScriptMaps = $Site.ScriptMaps
 
# Depending on the version of ASP.NET this is the Map we want to add:
$ScriptMap = ".html,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,"
 
$ScriptMaps += $ScriptMap
 
$Site.ScriptMaps = $ScriptMaps
$Site.SetInfo()
Open in New Window Select All
Random Solutions  
 
programming4us programming4us