views:

1048

answers:

1

I'm trying to assign application pool to one web site in IIS7 using vb script:

' Connect to the WMI WebAdministration namespace.'
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

' Retrieve the application and display its Web site name and path.'
Set oApp = oWebAdmin.Get("Application.SiteName='Default Web Site',Path='/site'")

' Specify a new application pool name and save it.'
oApp.ApplicationPool = "NewAppPool"
oApp.Put_

the above script is not working!

Is there is a better way to assign application pool to web site under IIS (Using script)?

+1  A: 

Are you setting the app pool on a web site or a virtual directory?

i.e., "Default Web Site/site" (virtual directory) or just "Site" (web site).

If you trying to set it on a web site, not a virtual directory, you need to do something like:

Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oSite = oWebAdmin.Get("Site.Name='Site'")
oSite.ApplicationDefaults.ApplicationPool = "NewAppPool"
oSite.Put_
Jim Fiorato