开发者

How to export Configuration of each IIS 6 Web Site using WMI

I need to export the WebSite Configuration (MetaBase) from IIS6 for a whole server, but I need each web site configuration to be saved separately. The result should be the same that can be obtained by right clicking on each Web Site in IIS Snap-in and selecting All Tasks->Save Configuration to a File. My idea is quite simple: 1- Using WMI, retrieve a list of Web Sites. 2- Also via WMI, export each configuration to a file having the same name of the Web Site.

However, I'm having some difficulties, mainly due to the complexity of WMI and, in my opinion, the poor documentation of its classes.

At the moment I found out how to enumerate Virtual Directories, but not Web Sites; while it's true that this method returns Web Sites as well, I can't see how to identify them among other virtual folders (a Web Site has different properties, which are not returned in the Virtual Directory Object), and I can't find the Web Site Description property, which I'd like to use to name the exported file.

I thought about a workaround for all the above issues, but it would be more a hack than a real solution... Any help if appreciated. Thanks.

UPDATE: I probably found what I was looking for, StackO开发者_开发问答verflow is so efficient that answers come to my mind as soon as I post on it. To list Web Sites, the query to run is

SELECT * FROM IISWebServerSetting

Quite "obvious"... Each Web Site Object contains its name in the "Server Comment" property (another "obvious" name). I'm going to do some more investigation, I have the feeling that this is just the tip of the iceberg.


I actually found the solution after a few days of research and I created a set of Scripts that exports IIS Web Sites and their Application Pools, cleans up/resets some Server-specific attributes (which can't be imported to another server) and generates an import script which can run against a target IIS6 or IIS7 with WMI enabled. Unfortunately, the ownership of such Scripts belongs to my previous employer, and I'm not allowed to post it publicly.

However, the key information I needed can be found here: Exporting and Importing Metabase Nodes Using WMI

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜