Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a ton (about 300) of IIS sites on a server that need to be moved to a new Application Pool. I could do it programmatically using the C# DirectoryEntry class, but I'm wondering if there's any easier way?

share|improve this question

4 Answers 4

ADSUtil.VBS is your friend here. You can use it to get a list of all sites on the system (which you will have to edit a bit to get the proper results), and to set the application pool for a site.

cscript adsutil.vbs enum /P /w3svc/

will give you a list of all paths on your server like this:

[/w3svc/1]
[/w3svc/2]
[/w3svc/608728754]
[/w3svc/608728755]
[/w3svc/87257621]
[/w3svc/AppPools]
[/w3svc/Filters]
[/w3svc/Info]

anything that ends with a number is a web site. After filtering that list, you can use it as input for another adsutil.vbs command:

cscript adsutil.vbs set W3SVC/<number>/ROOT/AppPoolId <NewAppPoolName>

Which will change the app pool for the web site specified by <number> to be whatever is specified in <NewAppPoolName> - this app pool must already exist.

Writing a wrapper around this in your favorite language should be pretty trivial if you are already talking about using C# to do this.

Also, if you aren't familiar with it, adsutil.vbs typically exists in c:\inetpub\adminscripts\

share|improve this answer

Programmin,g definitely. Nothing easier. Did you check the scripting section at http://www.iis.net/? Powershell also comes to my mind...

share|improve this answer

I wrote up a little tool to this based on the other answer. You can match the pools and sites based on regex, and it will divide them up evenly. You can download it here: http://www.netfuelinteractive.com/iis-application-pool-tools.aspx

share|improve this answer

I wrote up a little tool to this. You can match the pools and sites based on regex, and it will divide them up evenly. You can download it here: http://www.netfuelinteractive.com/iis-application-pool-tools.aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.