Posts tagged AhAdmin

Using ahadmin to read/write IIS configuration – Part 2

 Continuing my ahadmin drill down, lets see how to use available interfaces to work with section groups, section definitions, locations and metadata. IAppHostConfigFile interface Working with section groups, section definitions and locations require you to get an instance IAppHostConfigFile which is obtained using IAppHostConfigManager.GetConfigFile(). Following code gets IAppHostConfigFile instances for machine.config, root web.config, applicationHost.config and prints file path of each.

var ahwrite = new ActiveXObject("Microsoft.ApplicationHost.WritableAdminManager"); 

Using ahadmin to read/write IIS configuration – Part 1

The Application Host Administration API (ahadmin.idl) interface library can be accessed using native code and any COM-interop means like script or managed code. This blog post details how to use this interface in scripts (all samples are in javascript) to read/write IIS7 configuration information.

Getting/Setting property values

You start by getting an instance of IAppHostAdminManager if you want to only read the config. If you want to write to config as well, you will need an instance of IAppHostWritableAdminManager which derives from IAppHostAdminManager. IAppHostWritableAdminManager has additionally CommitChanges method to commit changes to disk and CommitPath get/set property which dictates where the configuration settings are written. Lets create an instance of these.