How to export Configuration of each IIS 6 Web Site using WMI
- by Diego
Hi all,
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.