8. Generating Windows PowerShell scripts using IIS Configuration Editor
Although IIS
Manager lets you configure many aspects of IIS, there are a number of
configuration settings that are not exposed in the user interface. To
configure these settings, you need to drill down and edit configuration
files like ApplicationHost.config,
the root configuration file that includes detailed definitions of all
sites, applications, virtual directories, and application pools on the
server, as well as global defaults for all web server settings. These
configuration files are schematized XML files, and you can either edit
them in Notepad (yikes!) or use the Configuration Editor, one of the
management features in IIS Manager.
New in IIS 8 is the capability of using the Configuration
Editor to generate a Windows PowerShell script for any configuration
changes that you make to your server using the Configuration Editor.
This capability can be particularly useful for cloud hosting providers
who need to automate the configuration of large numbers of web servers
because you can use such a generated script as a template for creating
a finished script that can perform the task that you need to automate.
Let’s see how this works. The section Application Initialization, discussed how you can globally configure
application pools on your server so that web applications on the server
are initialized before the first request comes in to access them. To
enable Application Initialization globally like this, you can edit the ApplicationHost.config file so that the following line in the <applicationPools> section:
<add name=".NET v4.5" managedRuntimeVersion="v4.0" />
changes to this:
<add name=".NET v4.5" startMode="AlwaysRunning" managedRuntimeVersion="v4.0" />
To do this using IIS
Manager, open the Configuration Editor and select applicationPools in
the system.applicationHost/applicationPools section as shown here:
Then you expand applicationPoolDefaults and change startMode from OnDemand to AlwaysRunning:
Once you’ve applied this change, you can click Generate Script in
the Actions pane. Doing this opens the Script Dialog dialog box, and on
the PowerShell tab is a PowerShell script that you can customize to
automate this configuration change on other servers in your farm: