views:

142

answers:

2

Basically, imagine you need to automate these steps:

  1. Open Internet Information Services.
  2. Find the web site, find the folder, right click the folder and select properties.
  3. Click the Directory folder.
  4. Under Applications settings, click the Create button. The application is now created. Click OK to finish.

(click for a pictoral walkthru)

My end goal is Powershell, but answers that use JScript or VB.NET or whatever are fine too.

Bonus points if the same code works against an IIS7 application running in 6.0 Compatibility Mode.

A: 

Check IIS6 Automation.

Edited to add

As requested: here.

Paulo Santos
I've written a ton of IIS6 automation already, but haven't found where this particular functionality lives. Care to be more specific?
Richard Berg
A: 

I've used this VBScript successfully. YMMV but at least it's a starting point.

' set a few constants
const CreateNewApplicationPool = true
const UseExistingApplicationPool = false

' Load the Metabase entry if the target directory does exist
Set IISWebDirObj = GetObject("IIS://" & objServer & "/W3SVC/" & objSiteID & "/Root/" & objApp)

if Err.Number <> 0 then
    Err.Clear
    ' Create the Metabase entry if the target directory does NOT exist
    Set IISWebDirRootObj = GetObject("IIS://" & objServer & "/W3SVC/" & objSiteID & "/Root")
    Set IISWebDirObj = IISWebDirRootObj.Create("IISWebDirectory", objApp)
end if

' Assign an existing app pool to the target directory
' Try AppCreate or Appcreate2 to create the app pool at the same time
'  or try using CreateNewApplicationPool for last parameter
IISWebDirObj.AppCreate3 2, objSvcPool, UseExistingApplicationPool

' set the name so it doesn't show up as: Default Application
IISWebDirObj.AppFriendlyName = objSvcPool
IISWebDirObj.SetInfo

' refresh the object in memory so we can change the app pool
IISWebDirObj.GetInfo  
IISWebDirObj.AppPoolId = objSvcPool
IISWebDirObj.SetInfo
Dennis Koch