views:

136

answers:

1

I'm currently in the process of upgrading old II6 automation scripts that use the IISVdir tool to create/modify/update apps and virtual directories, and replacing them with AppCmd for IIS7.

The IIS6, "IISVDir" commands reference paths in that are from the metabase, eg, /W3SVC/1/ROOT/MyApp - where 1 is ID of "Default Web Site". The command doesn't actually require the display name of the site to make changes to it.

This works well, since on a different language OS, the "Default Web Site" site name could be named, for example, "既定の Web サイト" or anything else for that matter. But this flexibility is lost if AppCmd can only reference "Default Web Site" via its name, and not a language-neutral identifier.

So, how can I script AppCmd to refer to sites, vdirs and apps using language neutral identifiers to reference the "Default App Site"?

Perhaps I need to start creating my own site instead, from the start, and name it something else specific, and stop using "Default Web Site" as the root?

Example of it in Japanese

(Disclosure: I only have a IIS7-English machine that I am working on currently, but I have both IIS6-English and IIS6-Japanese machines for testing my old scripts - so perhaps it really is just "Default Web Site" still on IIS7-Japanese?)

+1  A: 

The APPCMD tool appears only work with the site name (mostly). I asked a similar question on Server Fault a while back about exactly the same issue:

How do I reference a site by ID using IIS7 APPCMD? (ServerFault.com)

If you want to start working with the site by ID then you need to do this programmatically, for example:

int iisNumber = 1; // The default website
using (ServerManager serverManager = new ServerManager())
{
  var site = serverManager.Sites
       .Where(s => s.Id == iisNumber)
       .SingleOrDefault();

  if(site != null)
  {
    site.Stop();

    // Do stuff to site...

    site.Start();
  }
  serverManager.CommitChanges();
}
Kev
Thanks, I will probably build this into a small console app to just get the name of the site at a given site id argument. (Lame!)
Mike Atlas