How do I use IIS6 style metabase paths in IIS7 AppCmd ​​tool?

I am currently in the process of updating old II6 automation scripts that use the IISVdir tool to create / modify / update applications and virtual directories and replace them with AppCmd for IIS7.

The IIS6, "IISVDir" commands refer to the metabase, for example /W3SVC/1/ROOT/MyApp

- where 1 is the default Web site identifier. The command does not actually require the site display name to make changes to it.

This works well because in another OS language, the site name "Default Web Site" might be called, for example, "既定 の Web サ イ ト" or something else for that matter. But this flexibility is lost if AppCmd ​​can only refer to the "Default Website" through its name, and not a language neutral identifier.

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

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

Example of it in Japanese

(Disclosure: I only have an IIS7-English machine that I'm currently working on, but I have an IIS6-English and an IIS6-Japanese machine to test my old scripts - so maybe this is really a " default ", still in IIS7-Japanese?)

+2


a source to share


1 answer


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

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



If you want to start working with a site by identifier, you need to do it 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();
}

      

+3


a source







All Articles