[200 OK]: A Port80 Software Blog

We're all 200 OK: Web, HTTP and IIS Insights
posts - 199, comments - 719, trackbacks - 95

Put Your Sites In Order

A friend asked me today if I knew a way to change the display order of the sites in the Internet Services Manager.  His idea was a good one: On boxes where there are logical groupings among various sites (as for instance on certain staging or development boxes), it would be cool if the site listing you have to look at every time you open the ISM actually reflected that logic.  The default listing is effectively by order of creation, which might be, logically speaking, no better than random.

Now this particular friend happens to be an network admin with about a bazillion servers to take care of, on multiple platforms, and he doesn't always have time to satisfy his own curiosity about IIS niceties like this.  But then that's what I'm here for.

So the first thing I thought of was the site identifiers -- those long numbers that by default are displayed in the second column of the right-hand pane in the ISM.  (That is, in IIS 6.0; in IIS 5.0 they used to start at 1  and they were not displayed in the ISM at all.)  Since the ISM allows you to sort by any column, being able to renumber your sites would also give you a way to display them in any order you liked.

So what does it take to renumber your sites, you might ask?  It's not that hard actually.

First, you need to back up your metabase.  If that sounds like black magic, first go and read this to get some grasp of what the metabase actually is.  Then go here for detailed metabase backup/restore instructions.

So, your metabase is all backed up and you're ready to go.  Now you need a convenient way to edit the metabase.  For IIS 6.0, by far the most convenient way to do this is with the Metabase Editor that is available in the IIS 6 Resource Kit Tools (download them here).

Once you've got the Resource Kit Tools installed, run the Metabase Explorer.  In the tree control on the left, navigate down to LM/W3SVC and expand that node.  See all the sub-folders (or metabase keys) under there that have numbers for names?  Those numbers should correspond to the site identifiers in the second column of your ISM.  Still in the Metabase Editor, click on one of the numbered folders and look for the ServerComment field in the pane on the right (in the Name column); the value of this field (in the Data column) should correspond to the display name of the site in the ISM. 

Okay, now that you can identify your sites by metabase number, it's time to start renumbering them.  First, make sure in advance that you know the order you want your sites to appear in on the ISM.  You probably should do this on piece of paper to avoid mistakes (measure twice, cut once, as my metal shop teacher used to say). 

Just list the sites by display name (that is, ServerComment) exactly the way you want them to show up in the interface.  Then number them, top to bottom, staring at 1 (or a higher number, if you prefer). You should wind up with something that looks like this:

 1   www.dev.domain1.com
 2   www.stage.domain1.com
 3   www.dev.domain2.com
 4   www.stage.domain2.com

...and so on.  Now you are going to use the Metabase Editor to assign these new numbers to each site in turn.  It's really as simple as renaming a directory using Windows Explorer:  In the left pane of the Metabase Explorer, click on the numbered folder representing the site you want to change, then either click again or right-click and select "rename" from the context menu.  Delete the old, long number and type in the new one.  Once you've gone through and done this for each site -- and double-checked your work to make sure your numbering scheme is correct -- you're basically done.

Well, okay, not quite.  If you tried making an ASP request to one of your sites now, you wouldn't be happy with the results.  You also need to change the AppRoot field in the root folder, which is a child of the numbered site folder you were just operating in.  Don't panic, this is easy too.

Expand the numbered site folder, if it's not already expanded.  Highlight the “root” folder under the numbered site folder and look in the right-hand pane for the AppRoot field.  In the Data column, the value of it will be something like:

LM/W3SVC/123154540/Root

The part you want to change is the number.  This should be a repeat of the original metabase number of the site you are working in.  Change it so that it corresponds to the new site number.  Double-check that you have it right by looking back at the parent folder of the root folder you are currently in.  The number should be the same.

Once you've gone through and done this for all the sites, such that they have all been assigned their new metabase numbers (and corresponding AppRoots), close the Metabase Editor and restart IIS.  When you open (or refresh) the ISM, and select Web Sites, the display on the right will -- probably not be what you expect. 

What happened?  Well, you still need to click the label on the top of the Identifier column to sort by metabase number.  When you do so, you will (I hope) see the sites listed in the order you want.

Test everything to make sure it's still working.  If you get any failures -- well, obviously, it's time to restore using the metabase backup you made at the begining of this process.  You did make a metabase backup before getting started -- didn't you?

And that is all there is to it.  By the way, you can also order the display of virtual directories within a site, though it's a bit more tedious.  Brett Hill explains how its done (for Windows 2000 at least) here.

 


 

posted on Thursday, February 10, 2005 7:17 PM

Feedback

# Put Your Sites in Order, Part II

2/11/2005 4:40 PM | [200 OK]: A Port80 Software Blog

# Put Your Sites in Order, Part II

8/16/2006 4:26 PM | [200 OK]: A Port80 Software Blog

# re: Put Your Sites In Order

I have done this with IIS 5.1, however it seems that this version orders the sites by their physical ordering in the metabase file. I manage over 40 sites, and use IISAdmin.NET to quickly switch between them. It would be much less of a headache to be able to order my sites alphabetically, rather than in the mixed up order in which they were created. If you have any tips, please share them! webmaster@mestek.com
Regards,
-Tom
3/29/2007 6:12 AM | Tom

# re: Put Your Sites In Order

If anyone else finds the method proposed a bit hairy and just needs to get an alpha sorted list of their sites, click the 'Web Sites' folder icon in the IIS manager. This will show all sites in the right-hand panel with header tabs that can be clicked on (including site name, identifier, host, IP etc.)
9/6/2007 2:08 AM | Ralph Windsor

# re: Put Your Sites In Order

Thank you
4/7/2008 8:07 AM | software

Post Comment

Title:  
Name:  
Url:  
Comment:  
Verify:
(Enter the word as it appears in the box above.)