Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (39 sloc) 3.27 KB
title author description ms.date ms.assetid msc.legacyurl msc.type
PowerShell Snap-in: Advanced Configuration Tasks
thomasdeml
In this walkthrough you will learn how to accomplish some advanced configuration tasks using XPath queries and wildcards. Introduction The previous walkthrou...
04/14/2008
27fd5104-49f1-463f-ad33-effa4b3b4e45
/learn/manage/powershell/powershell-snap-in-advanced-configuration-tasks
authoredcontent

PowerShell Snap-in: Advanced Configuration Tasks

by Thomas Deml

In this walkthrough you will learn how to accomplish some advanced configuration tasks using XPath queries and wildcards.

Introduction

The previous walkthrough introduced you to the *-WebConfiguration and *-WebConfigurationProperty cmdlets. There is more to these cmdlets than meets the eye. The -filter parameter is not just a way to specify a configuration section. It is an XPath query and in this walkthrough we'll explore how to take advantage of it. There are also some nice ways you can use wilcards with the *-WebConfiguration* commands.

This walkthrough uses the sites, applications and virtual directories created in previous examples.

Using XPath Queries

Here is a simple example that shows you how to use wilcards with the Get-WebConfigurationProperty cmdlet:

[!code-powershellMain]

And another one. Here all the handler mappings that will get executed by ASPNET_ISAPI.DLL:

[!code-powershellMain]

Let's suppose you don't like the .aspx extension for your ASP.Net files too much and you want to change all IIS handler mappings from *.aspx to *.mspx. Can it be shorter than this?

[!code-powershellMain]

Let's look if the changes were set:

[!code-consoleMain]

Now how about looking at the configuration file itself. We can use the get-item cmdlet that we explored in a previous walkthrough.

[!code-powershellMain]

You can see that the configuration system removed the old handlers and replaced them with new handlers that are now mapped to *.mspx.

Discovering IIS Configuration

It's great if you know what you want to configure. But what if you don't. Here are a few helpers.

Showing available IIS configuration sections

[!code-powershellMain]

Showing the properties you can configure on a particular section:

[!code-powershellMain]

Putting the two together, i.e. showing all sections with their properties.

[!code-powershellMain]

We will probably pack these commands into some functions at a later Tech Preview but this is what you get for now :).

Summary

In this walkthrough you learned how to accomplish complex IIS configuration tasks by using wildcards and XPath queries. The next walkthrough will discuss how to discover state and run-time data.

You can’t perform that action at this time.