<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.iis.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:cs="http://blogs.iis.net/"><channel><title>Blog:\&amp;gt;_ : XPath</title><link>http://blogs.iis.net/sergeia/archive/tags/XPath/default.aspx</link><description>Tags: XPath</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>How to change output format in PowerShell</title><link>http://blogs.iis.net/sergeia/archive/2008/08/29/how-to-change-output-format-in-powershell.aspx</link><pubDate>Fri, 29 Aug 2008 09:03:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2588273</guid><dc:creator>sergeia</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/sergeia/rsscomments.aspx?PostID=2588273</wfw:commentRss><comments>http://blogs.iis.net/sergeia/archive/2008/08/29/how-to-change-output-format-in-powershell.aspx#comments</comments><description>&lt;P&gt;I was looking around the Net today and stumbled on &lt;A href="http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx" mce_href="http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx"&gt;the post in Scott Hanselman's blog&lt;/A&gt;, where he talks about technical and marketing aspects of product naming in Microsoft. There he shows display format for IIS application pools that may be relevant to servers, where admins keep multiple versions of CLR and run applications in various modes. This output includes managed runtime version for the pool and mode (integrated or classical) for the pool. By default IIS provider shows only name, state and list of applications, assigned to this pool. It is pretty easy to change this output to what Scott prefers.&lt;/P&gt;
&lt;P&gt;Open file iisprovider.format.ps1xml (name could be changed in next release) and find view, defined there for application pool. This will be piece of XML tagged by type name "Microsoft.IIs.PowerShell.Provider.NavigationNode#AppPool". This typename means that as soon as PowerShell will find object in the output stream, which has this type name in its typenames collection, it will use this view. View selected once for the first object in output stream -- this is pretty annoying shortcoming in PowerShell because in IIS configuration it is common to have objects of multiple types in output.&lt;/P&gt;
&lt;P&gt;OK, now you have to create new XML file with the name you like, and extension "format.ps1xml", say PoolModeView.format.ps1xml. Then add there header and footer:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="utf-8"&lt;/SPAN&gt;?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Configuration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;ViewDefinitions&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0px
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;PRE class=csharpcode&gt;  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;ViewDefinitions&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Configuration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/P&gt;
&lt;P&gt;Select whole section with pool view in original file and copy it into your new file. We will modify this view to add new columns. We have to change name of the view first. Let's name it "appPoolModeView". Then add new column definitions after the State column:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;State&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;12&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;left&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;CLR Version&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;12&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;left&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Mode&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Label&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;12&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;left&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Alignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnHeader&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/P&gt;
&lt;P&gt;That will be our column headers. We have to define, what to show in these columns. After section TableColumnItem for State, add the following:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;State&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;managedRuntimeVersion&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;managedPipelineMode&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/P&gt;
&lt;P&gt;We will display two properties that identify CLR runtime and mode. Now we could save our file. In PowerShell window run the following command:&lt;/P&gt;
&lt;P&gt;PS C:\ #&amp;gt; Update-FormatData -prependpath &amp;lt;path-to-your-file&amp;gt;&lt;/P&gt;
&lt;P&gt;Depending on your settings in PowerShell you may see an error, because new file is not signed. As a long term solution you will need &lt;A class="" href="http://www.hanselman.com/blog/SigningPowerShellScripts.aspx" mce_href="http://www.hanselman.com/blog/SigningPowerShellScripts.aspx"&gt;to sign this file&lt;/A&gt; the same way you are signing scripts, for now you could relax execution policy to RemoteSigned.&lt;/P&gt;
&lt;P&gt;Let's see what we get:&lt;/P&gt;
&lt;P&gt;PS C:\ #&amp;gt; cd iis:\apppools&lt;/P&gt;&lt;PRE class=csharpcode&gt;PS IIS:\AppPools &lt;SPAN class=rem&gt;#&amp;gt; dir&lt;/SPAN&gt;

Name                  State     CLR Version  Mode         Applications
----                  -----     -----------  ----         ------------
DefaultAppPool        Started   v2.0         Integrated   Default Web Sit
                                                          e
                                                          mysite
                                                          /appDefault
                                                          /myapp
Classic .NET AppPool  Started   v2.0         Integrated
newPool               Started   v2.0         Integrated&lt;/PRE&gt;
&lt;P&gt;If you want to have this view, but don't like to use it by default, run update-formatdata without -prependpath. PowerShell will add your view to the internal tables, but still will use the old one. To enable new output format, add "format-table -view apppoolmodeview" to your output command, and you will get this view.&lt;/P&gt;
&lt;P&gt;PS IIS:\AppPools #&amp;gt; dir | ft -view appPoolModeView&lt;/P&gt;
&lt;H4&gt;XPath in output formatting&lt;/H4&gt;
&lt;P&gt;While we discussing output formatting, let me show how you could extend output for any object by adding pieces of script into the view. This script block could get any data and add it to your output. Look how I did it for application pool view. The last column shows applications, assigned to this pool. But pool structure doesn't include any indication about applications. To find which applications belong to the pool, we have to look through all applications and select those having property "applicationPool" set to the name of our pool. Let's take a look how we form column for applications (I inserted back ticks into long lines to fit them on screen):&lt;/P&gt;
&lt;DIV align=left&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;ScriptBlock&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    $pn = $_.Name
    $sites = get-webconfigurationproperty `
      "/system.applicationHost/sites/site/`&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;      application[@applicationPool=`'$pn`'and `&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;      @path='/']/parent::*" `
      machine/webroot/apphost -name name
    $apps = get-webconfigurationproperty `
      "/system.applicationHost/sites/site/`&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;      application[@applicationPool=`'$pn`'and `&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;      @path!='/']" `
      machine/webroot/apphost -name path
    $out = ""
    foreach ($s in $sites + $apps) {$out = $out + $s + "`n"}
    $out = $out.Substring(0, $out.Length - 1)
    $out
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;ScriptBlock&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;TableColumnItem&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P align=left&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/P&gt;
&lt;P&gt;In our namespace we are hiding root applications and root virtual directories, and moved their properties to sites. That's another XPath query, but in namespace definition for site. Because we need both sites and applications, scriptblock runs two queries. First it selects all root applications (with path'/') that are assigned to our pool (with name $pn). For each path query selects parent node for application, i.e. site, and returns name of this site. Second query selects names of all non-root applications with the same setting. Next line does the trick that shows all entries inside of column -- it appends each name from combined list to the string variable, and adds symbol &amp;lt;CR&amp;gt; after that. Then script removes the last &amp;lt;CR&amp;gt; and outputs the resulting string. When output module in PowerShell formats the view, it wraps strings inside of column, and inserted &amp;lt;CR&amp;gt; symbols point to end of each row.&lt;/P&gt;
&lt;P&gt;Certainly, one could write script block that doesn't use XPath, but this would be much longer code with multiple loops and conditions. XPath takes one query string and returns result with minimal overhead.&lt;/P&gt;
&lt;P&gt;Enjoy,&lt;/P&gt;
&lt;P&gt;Sergei Antonov&lt;/P&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2588273" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/sergeia/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.iis.net/sergeia/archive/tags/XPath/default.aspx">XPath</category><category domain="http://blogs.iis.net/sergeia/archive/tags/output+views/default.aspx">output views</category><category domain="http://blogs.iis.net/sergeia/archive/tags/output+formatting/default.aspx">output formatting</category></item><item><title>How we use XPath in IIS PowerShell namespace</title><link>http://blogs.iis.net/sergeia/archive/2008/08/28/use-of-xpath-in-iis-powershell-namespace.aspx</link><pubDate>Thu, 28 Aug 2008 07:18:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2585533</guid><dc:creator>sergeia</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/sergeia/rsscomments.aspx?PostID=2585533</wfw:commentRss><comments>http://blogs.iis.net/sergeia/archive/2008/08/28/use-of-xpath-in-iis-powershell-namespace.aspx#comments</comments><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;IIS 7 configuration API's were designed as DOM: you always have to start from top level data structure and work your way to the data you need, either collection element or child element attributes. It is quite annoying model when you are building generic tools, and soon we started looking for some way of cutting off amount of code required for access of internal collections and attributes. At some moment we realized that we could use System.Xml.XPath.XPathNavigator type to expose IIS configuration. This type could be used to represent any hierarchical data as tree for XPath queries, not necessarily originated in XML. That was a perfect fit: with XPath query we could access any entity inside of configuration in one step. First CTP of provider was based on this approach. It worked nice but was pretty slow. Keeping XPath engine in managed code introduced major performance bottleneck: configuration data are in non-managed code, and XPath engine should marshal across the border every piece of data during processing of query. To make it better, fearless IIS developer William Moy created XPath query processor in native code, following the same model as XPathNavigator, and second CTP of provider is based on this engine. It is so effective, that when we access internal data inside of configuration section using fully qualified path it takes in average only 10% longer than using straight code based on explicit configuration API's, when this code accesses the same data. Fully qualified here means that path points to the unique data inside of configuration, and query don't need to walk around big parts of tree.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;As you probably know, configuration system in IIS 7 is distributed, and is merged from multiple configuration files located in root folders of virtual directories and file system folders below them. Path that points to any of these containers for configuration files named &lt;EM&gt;commit path&lt;/EM&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;XPath engine works with the search tree built from IIS configuration sections, merged from files which were gathered along some commit path. The tree has root, represented by root section group, then it includes child groups and sections, then child elements and collection elements, so it is kind of like Object Viewer tree in Visual Studio, rather than file system tree. If written properly, XPath query could return just one unique piece of data from configuration, in that case we could use it as universal addressing format for configuration data. Or it could select set of nodes from the search tree, in that case it is good to describe groups of data, for example, all sites, or all applications of the site, etc. If we store these queries into some place, we could describe our own namespace, composed from data extracted from configuration by these stored queries. &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;XPath queries are the backbone of IIS 7 PowerShell namespace: if you open file NavigationTypes.xml, you will see that most of things in the namespace are described as XPath queries, for example,&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" New?;="New?;" ?Courier="?Courier" mso-bidi-font-family:="mso-bidi-font-family:" roman?,?serif?;="roman?,?serif?;" times="times"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" mso-bidi-font-family:="mso-bidi-font-family:" 12.0pt?="12.0pt?" mso-bidi-font-size:="mso-bidi-font-size:" Roman?;="Roman?;" new?;="new?;" courier="courier"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" mso-bidi-font-family:="mso-bidi-font-family:" 12.0pt?="12.0pt?" mso-bidi-font-size:="mso-bidi-font-size:" Roman?;="Roman?;" new?;="new?;" courier="courier"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" mso-bidi-font-family:="mso-bidi-font-family:" 12.0pt?="12.0pt?" mso-bidi-font-size:="mso-bidi-font-size:" Roman?;="Roman?;" new?;="new?;" courier="courier"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" mso-bidi-font-family:="mso-bidi-font-family:" 12.0pt?="12.0pt?" mso-bidi-font-size:="mso-bidi-font-size:" Roman?;="Roman?;" new?;="new?;" courier="courier"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" roman?,?serif?;="roman?,?serif?;" times="times"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" mso-bidi-font-family:="mso-bidi-font-family:" 12.0pt?="12.0pt?" mso-bidi-font-size:="mso-bidi-font-size:" Roman?;="Roman?;" new?;="new?;" courier="courier"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" roman?,?serif?;="roman?,?serif?;" times="times"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;FONT color=#000080&gt;&lt;SPAN class=kwrd&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;FONT color=#000080&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;virtualDirectory&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; ...&lt;BR&gt;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;InstanceXPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;%parent::InstanceXPath%/virtualDirectory[@path="%path%"]&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;InstanceXPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; ...&lt;BR&gt;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;children&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;childInfo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;childType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;fileDirectory&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;childType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;xPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;%InstanceXPath%/physicalPath&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;xPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;childInfo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;childInfo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;childType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;file&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;childType&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;xPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;%InstanceXPath%/physicalPath&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;xPath&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;childInfo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;children&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;virtualDirectory&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;This description instructs code in provider how to list virtualDirectory namespace nodes, how to produce list of child nodes for this node. Names in %% are macros referring to namespace object properties, or its parent properties. When user wants to get object, provider resolves InstanceXPath using specific instance as parent and sends expanded query strings to XPath engine, then it uses resulting selection to build namespace object. This approach is very flexible: if I want to rearrange the tree, all I need to do is to modify this XML file; if I want to add new namespace type, based on configuration object from some section, in most cases I only add its description to this XML tree. After restart of PowerShell IIS provider will resolve it and new type will be exposed in the namespace. Format of namespace description was changed a bit after CTP2 to enable addition of new description files, so you could use this model to extend our namespace and include your objects.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;XPath queries directly accessible for user through base level commands: get-webconfiguration and set-webconfiguration. There are two more commands that work with properties, they also consume XPath queries to address object owning properties. Our XPath engine actually works with two trees, one combined from sections, elements and attributes, and another one -- from commit paths. This commit path engine is used, for example,&amp;nbsp; when we want to retrieve configuration recursively starting from some entry point on commit path tree, say, from some particular site. When you run command&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;get-webconfiguration /system.webServer/asp/limits/@requestQueueMax "iis:\sites\default web site" -recurse&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;it will return all setting for asp section attribute requestQueueMax, existing down the tree from "Default Web Site". To direct query down the tree, provider internally resolves namespace path, and when -recurse is specified, converts it into "MACHINE/WEBROOT/APPHOST/Default Web Site/descendant-or-self::node()". This expression tells query engine that it should not limit search by one level, and should go down the tree. Another part, configuration XPath is also modified to "/system.webServer/asp/limits/@requestQueueMax[is-locally-defined()]". Function in square brackets is specific to IIS configuration navigator, it returns "true" if attribute was defined on some particular level, otherwise query will return all inherited values for this attribute. Our XPath engine defines several functions like this one, I will describe all of them later.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;This is an example of simplest XPath query. You could write much more complicated expressions and get more specific data from configuration. I recommend to learn a bit about XPath, if you want to use our "platform" level functionality to write you own scripts and functions in PowerShell, you will be surprised, how much you could achieve in just couple of line. You could find pretty good practical courses in XPath in many places in the Net, some sites offer visual XPath editor that shows result of your query applied to sample data file.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;Almost all helper commands that we released in CTP2 were built very quickly and are all based on base level commands. Each simplified cmdlet is nothing more but piece of code that declares parameters, then compiles low level command from user input and calls get-webconfiguration or other command. You could do the same for cmdlet specific to your needs. If you are using PowerShell v2.0, you could write script based cmdlets instead of compiled code. Let me show you one example of helper command.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;PS IIS:\#&amp;gt; get-command new-webbinding | select definition | fl * &lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;Definition : New-WebBinding [-Site] &amp;lt;String&amp;gt; [-Port &amp;lt;UInt32&amp;gt;] [-IPAddress &amp;lt;String&amp;gt;] [-HostHeader &amp;lt;String&amp;gt;] [-Ssl] [-Force] ...&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;For clarity I removed parameters inserted by PowerShell. This cmdlet defines all parameters that we need to create binding on some site: site name, port, ipaddress, host header and ssl switch, that tells us that we have to build binding for ssl. Internal code then compiles another command:&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;new-itemproperty IIS:\sites\&amp;lt;site_name&amp;gt; -name Bindings -value @{protocol="http";bindingInformation="&amp;lt;IPAddress&amp;gt;:&amp;lt;Port&amp;gt;:&amp;lt;Host_Header&amp;gt;"}&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;Here is the source code for ProcessRecord method of the cmdlet, it uses couple of utility functions to format error message and to invoke resulting script. I assume that you are familiar with details of PowerShell SDK and know how to write cmdlets. PowerShell v1.0 doesn't show errors happened in internally called script, therefore I have to check $error variable and if there is an error, print it in my utility function. In v2.0 that was already fixed.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;... &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;protected override void ProcessRecord() &lt;BR&gt;{ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StringBuilder cmdLine = new StringBuilder("new-itemproperty "); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string protocol = "http"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (sslBinding.IsPresent) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protocol = "https"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append("\"IIS:\\sites\\" + siteName + "\" "); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(" -name Bindings -value @{protocol=\""); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(protocol); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append("\";bindingInformation=\""); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!ipAddress.Equals("*")) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IPAddress test = IPAddress.Any; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!IPAddress.TryParse(ipAddress, out test)) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new ArgumentException(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.FormatResourceString( &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;"InvalidIPAddress", ipAddress)); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(ipAddress); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (sitePort == 0xFFFFFFFF) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sitePort = (uint)(sslBinding.IsPresent ? 443 : 80); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(":" + sitePort.ToString() + ":"); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!String.IsNullOrEmpty(hostHeader)) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(hostHeader); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (!sslBinding.IsPresent) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(siteName); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append("\"}"); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Force.IsPresent) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.Append(" -force"); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.InvokeScriptShowError(this, &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" new?;="new?;" courier="courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmdLine.ToString()); &lt;BR&gt;} &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;... &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;That's all you need to make it work. It is a simple command, most of source code is required to declare and describe parameters, I spent half an hour to write it, and as a result user could avoid typing expression for PowerShell hastable @{...}, so unpopular in PowerShell MVP circles and could omit some parameters altogether.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;In my next post I will show you some less trivial queries that could produce more exciting results.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal style="MARGIN: 6pt 0in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 6pt 0in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" arial?,?sans-serif?;="arial?,?sans-serif?;" roman??="Roman??"&gt;Sergei Antonov&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; FONT-FAMILY: " new="new" ?Times="?Times" mso-fareast-font-family:="mso-fareast-font-family:" roman??="Roman??" mso-bidi-font-family:="mso-bidi-font-family:" Roman?;="Roman?;" ms?,?sans-serif?;="ms?,?sans-serif?;" trebuchet="trebuchet"&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2585533" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/sergeia/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.iis.net/sergeia/archive/tags/XPath/default.aspx">XPath</category></item></channel></rss>