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:
PowerShell
PS IIS:\Sites\DemoSite\DemoApp> Get-WebConfigurationProperty -filter //defaultDocument/files -name Collection[value="index*"] | select value
And another one. Here all the handler mappings that will get executed by ASPNET_ISAPI.DLL:
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?
Showing the properties you can configure on a particular section:
PowerShell
get-webconfiguration system.webServer/caching | select -exp Attributes | select Name
Putting the two together, i.e. showing all sections with their properties.
PowerShell
get-webconfiguration //* | where {$_.psbase.SectionPath -like"*" -and$_.psbase.SectionPath.length -gt0} | foreach {$_.SectionPath.ToUpper();get-webconfiguration$_.SectionPath | select -exp Attributes | select Name;"`n"} | more
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.
This learning path covers Windows Management Instrumentation (WMI) and Common Information Model (CIM). These technologies help to access information about a computer. Additionally, both technologies provide local and remote access to management information from the operating system, computer hardware, and installed software.
In the previous walkthrough you learned how to manage IIS namespace containers like Sites, Application Pools, Applications and Virtual Directories. In this w...
In this walkthrough you will learn how to change simple properties of IIS namespace containers like Web-Sites, Web Applications, Virtual Directories and Appl...
IIS PowerShell Snap-in cmdlets can be grouped into three categories: Cmdlets required by the Provider Hierarchy low-level configuratioin cmdlets Task-based c...
With PowerShell shipped, IIS administrators get a new tool to use. The following article concentrates on administration tasks for IIS 7.0 and above; however,...
Everybody is familiar on how the file system is organized. File systems are hierarchical namespaces, comprised of directories that contain files and other di...
Windows PowerShell is Microsoft's shell and scripting language. This short article provides a brief tour of Windows PowerShell and IIS. Reading this article,...
The previous walkthroughs showed you how to query and change IIS configuration settings. There is one unexplored area left however: run-time data. Introducti...