<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; CTP3</title>
	<atom:link href="http://huddledmasses.org/tag/ctp3/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Fri, 27 Apr 2012 05:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>A guide to PowerShell&#8217;s Advanced Functions</title>
		<link>http://huddledmasses.org/a-guide-to-advanced-functions/</link>
		<comments>http://huddledmasses.org/a-guide-to-advanced-functions/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:44:03 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Advanced Functions]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell 2]]></category>
		<category><![CDATA[PowerShell Functions]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WalkThrough]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1116</guid>
		<description><![CDATA[Someone asked on the PowerShell Newsgroup about writing Advanced Functions, and specifically: looking for a &#8230; guide to putting together an advanced function that is visible and usable every time I start Powershell. By visible I mean that when I do a &#8216;get-command&#8217; I want my [advanced function]s to be listed alongside all the regular [...]]]></description>
			<content:encoded><![CDATA[	<p>Someone asked on the <a href="news://msnews.microsoft.com:119/microsoft.public.windows.powershell">PowerShell Newsgroup</a> about writing Advanced Functions, and specifically:</p>

	<blockquote>
		<p>looking for a &#8230; guide to putting together an advanced function that is visible and usable every time I start Powershell. By visible I mean that when I do a &#8216;get-command&#8217; I want my [advanced function]s to be listed alongside all the regular cmdlets. What makes that possible? ... what do I need to do to make that happen? Whats the difference between an [advanced function] and a module?</p>
	</blockquote>

	<p>There are lots of articles on the Microsoft <a href="http://blogs.msdn.com/powershell/">PowerShell team blog</a> about both topics, but it seems there&#8217;s not really been any sort of step-by-step written, so I posted this to the newsgroup, and since the person who asked the original question said he found it useful, I figured I&#8217;d share it here&#8230;</p>

<span id="more-1116"></span>

	<h2>An Aside: Advanced Functions vs. Modules</h2>

	<p>Advanced functions and script modules are unrelated topics. A script module could have nothing but old PowerShell 1 -type functions, hypothetically, it could even not have any functions at all.  Advanced functions can be defined in a plain .ps1 script, in your profile, or by typing them in on the command-line, etc. The two things are essentially unrelated except for both being new features in PowerShell 2.0.</p>

	<h2>How To write an Advanced Function</h2>

	<h3>Step 1: Have something you want to do in a function.</h3>

	<p>I can&#8217;t emphasize enough how important it is that you should have a specific goal here. Writing a script for a specific purpose is much easier, because you don&#8217;t have to think about whether or not specific features are necessary, etc.</p>

	<p>For the purposes of this example, I want a function to start executables and return me the process object (so I can wait for it to finish, or whatever). I will call it Start-Process.</p>

	<h3>Step 2: Write a first step for the logic of your function. </h3>

	<p>Be sure to specify the parameters using the <code>function Name{Param(...)}</code> syntax rather than <code>function Name(...){}</code>, then you will be able to easily convert it to an advanced function by adding <code>[CmdletBinding()]</code> on the line right before the <code>Param</code> like this:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666699; font-weight: bold;">function</span> <span style="color: #0066cc; font-style: italic;">Start-<span style="font-style: normal;">Process</span></span> <span style="color: #333;">&#123;</span><br />
<span style="color: #333;">&#91;</span>CmdletBinding<span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
<span style="color: #666699; font-weight: bold;">param</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$app</span>,<span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$param</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$app</span>, <span style="color: #660033; font-weight: bold;">$param</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span> <span style="color: #666699; font-weight: bold;">else</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$app</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span></div>

	<h3>Step 3: Start writing documentation and auto-help, including your parameters.</h3>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666699; font-weight: bold;">function</span> <span style="color: #0066cc; font-style: italic;">Start-<span style="font-style: normal;">Process</span></span> <span style="color: #333;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#.Synopsis</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Starts an application, with optional command-line parameters.</span><br />
<span style="color: #666666; font-style: italic;">#.Parameter App</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;The path to the application you want to start</span><br />
<span style="color: #666666; font-style: italic;">#.Parameter Params</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;The string consisting of all the parameters to pass to App</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #333;">&#91;</span>CmdletBinding<span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
<span style="color: #666699; font-weight: bold;">param</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$app</span>,<span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$param</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$app</span>, <span style="color: #660033; font-weight: bold;">$param</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span> <span style="color: #666699; font-weight: bold;">else</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$app</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span></div>

	<h3>Step 4: Exploit advanced features by marking up your parameters.</h3>

	<p>In my case, I had a look at the signature of the start method by running <code>[Diagnostics.Process]::Start.OverloadDefinitions</code> and discovered that it can take credentials too.  So I wanted an <em>optional</em> credential parameter. I specified it without a <strong>position</strong>, and made it part of a non-default parameter set.</p>

	<p>I also wanted the <code>params</code> parameter to just take any additional parameters which I pass to the function, and pass them on to the process that I&#8217;m starting. </p>

	<p>Finally, I wanted the &#8220;App&#8221; parameter to be able to come from the pipeline. Specifically, I wanted to be able to pass the output of Get-Command or Get-ChildItem to it. In order to enable that, I defined an alias on it to the relevant properties of the objects which come from those two commands</p>

	<p>Hopefully you&#8217;re getting the idea of what&#8217;s possible here &#8230;</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666699; font-weight: bold;">function</span> <span style="color: #0066cc; font-style: italic;">Start-<span style="font-style: normal;">Process</span></span> <span style="color: #333;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#.Synopsis</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Starts an application, with optional command-line parameters.</span><br />
<span style="color: #666666; font-style: italic;">#.Parameter App</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;The path to the application you want to start</span><br />
<span style="color: #666666; font-style: italic;">#.Parameter Params</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;The string consisting of all the parameters to pass to App</span><br />
<span style="color: #666666; font-style: italic;">#.Parameter Credential</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;PSCredential containing valid login to &quot;run as&quot; another user.</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #333;">&#91;</span>CmdletBinding<span style="color: #333;">&#40;</span>DefaultParameterSetName<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;NoCreds&quot;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
<span style="color: #666699; font-weight: bold;">param</span><span style="color: #333;">&#40;</span><br />
&nbsp; <span style="color: #333;">&#91;</span>Parameter<span style="color: #333;">&#40;</span>Position<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>,Mandatory<span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$true</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ValueFromPipelineByPropertyName<span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$true</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
&nbsp; <span style="color: #333;">&#91;</span>Alias<span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;FullName&quot;</span>,<span style="color: #009900;">&quot;Path&quot;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$app</span><br />
,<br />
&nbsp; <span style="color: #333;">&#91;</span>Parameter<span style="color: #333;">&#40;</span>Mandatory<span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$true</span>,ParameterSetName<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;RunAs&quot;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
&nbsp; <span style="color: #333;">&#91;</span>Alias<span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;PSCredential&quot;</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#93;</span><br />
&nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>System.<span style="color: #003366;">Management</span>.<span style="color: #003366;">Automation</span>.<span style="color: #003366;">PSCredential</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$Credential</span><br />
,<br />
&nbsp; <span style="color: #333;">&#91;</span>Parameter<span style="color: #333;">&#40;</span>Position<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">3</span>, Mandatory<span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$false</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ValueFromRemainingArguments<span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$true</span> <span style="color: #333;">&#41;</span><br />
&nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">string</span><span style="color: #333;">&#91;</span><span style="color: #333;">&#93;</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$params</span><br />
<span style="color: #333;">&#41;</span><br />
<br />
&nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$credential</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$cred</span><span style="color: #66cc66;">=</span><span style="color: #660033; font-weight: bold;">$credential</span>.<span style="color: #003366;">GetNetworkCredential</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$app</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">string</span><span style="color: #333;">&#93;</span></span>::<span style="color: #333399; font-weight: bold; font-style: italic;">join</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot; &quot;</span>,<span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$cred</span>.<span style="color: #003366;">UserName</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$credential</span>.<span style="color: #003366;">Password</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$cred</span>.<span style="color: #003366;">Domain</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#125;</span> <span style="color: #666699; font-weight: bold;">else</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$app</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$cred</span>.<span style="color: #003366;">UserName</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$credential</span>.<span style="color: #003366;">Password</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$cred</span>.<span style="color: #003366;">Domain</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; <span style="color: #333;">&#125;</span> <span style="color: #666699; font-weight: bold;">else</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$app</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">string</span><span style="color: #333;">&#93;</span></span>::<span style="color: #333399; font-weight: bold; font-style: italic;">join</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot; &quot;</span>,<span style="color: #660033; font-weight: bold;">$params</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#125;</span> <span style="color: #666699; font-weight: bold;">else</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Diagnostics.<span style="color: #666699; font-weight: bold;">Process</span><span style="color: #333;">&#93;</span></span>::<span style="color: #660033;">Start</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$app</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; <span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span></div>

	<h3>Bonus Step: Make the function be automatically defined</h3>

	<p>To be honest, there are a lot of ways to do this, here&#8217;s a few:</p>

	<h4>Option 1. Define it in your Profile.</h4>

	<p>Include the full text of the function in your Profile.ps1 script or Microsoft.PowerShell_profile.ps1 &#8230; just run <code>notepad $Profile</code> and paste the whole function in at the top, then save.</p>

	<h4>Option 2. Dot-source it in your Profile.</h4>

	<p>Save the function into a script file, e.g.: &#8220;StartProcessFunction.ps1&#8221; in your DocumentsWindowsPowerShell folder (next to your profile script) then put the line: <code>. StartProcessFunction.ps1</code> into your profile script to dot-source it. Using the dot causes the script to be loaded into the context as though you had put the contents of the script in, instead of the dot-source line. </p>

	<h4>Option 3. Import this function from a script file.  </h4>

	<p>This is basically the same as Option 2, except instead of &#8220;.&#8221; you can use <code>Import-Module</code>.  The Import-Module cmdlet, when used on a file with the .ps1 extension, is basically the same as dot-sourcing it, so there&#8217;s not a whole lot of benefit over dot-sourcing in this case.</p>

	<h4>Option 4. Put the function in a module.</h4>

	<p>You should <strong>only</strong> do this if you think <em>you might want to add additional functions</em> to the module. For instance, lets say you want to write a few other functions for working with process objects.  If you put them together in the same module (say: &#8220;ProcessUtility&#8221;) they can share script-scoped variables or private functions, and can be identified as being part of the same module using the <code>Get-Command -Module ProcessUtility</code> command. </p>

	<p>If you just have the single function, there&#8217;s really no point in changing it to a Module, but I&#8217;m not aware of any downside, either.</p>

	<h4>Option 4a. Make a module by just saving as a <code>.psm1</code></h4>

	<p>All you do is save the function into a module file, e.g.: &#8220;ProcessUtility.psm1&#8221; in your DocumentsWindowsPowerShell folder and then put the line: <code>Import-Module ProcessUtility.psm1</code> into your profile script.</p>

	<h4>Option 4b. Make a module folder.</h4>

	<p>This is by far the most extensible way to create modules. You paste the function into &#8220;ProcessUtility.psm1&#8221; and then save it into a folder &#8220;ProcessUtility&#8221; which must be created in one of your module folders. You can figure out where the module folders are by checking <code>$Env:PSMODULEPATH</code> &#8212; the normal spot is your DocumentsWindowsPowerShellModules. </p>

	<p>Once that&#8217;s done, you can import with the simpler command <code>Import-Module ProcessUtility</code> without any extension. </p>

	<p>The nice thing about creating the folder is that you can put any additional resources in that folder with it, and get at them using the <code>$PsScriptRoot</code> to define the folder. You can even add additional functions by putting them in separate files (which you can Import-Module from the main file, or you can define using a .psd1, but that&#8217;s <a href="http://huddledmasses.org/powershell-modules-metadata-and-mysteries/">another article</a>).</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/a-guide-to-advanced-functions/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PowerShell 2 CTP3 &#8211; Custom Accelerators, Finally!</title>
		<link>http://huddledmasses.org/powershell-2-ctp3-custom-accelerators-finally/</link>
		<comments>http://huddledmasses.org/powershell-2-ctp3-custom-accelerators-finally/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 06:28:38 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Adaptive Type System]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Features]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Type Accelerator]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/powershell-2-ctp3-custom-accelerators-finally/</guid>
		<description><![CDATA[Have I mentioned lately how much Oisin Grehan (a.k.a.: x0n) rocks? He discovered that in PowerShell 2 we can now define our own custom type accelerators. A &#8220;Type Accelerator&#8221; is the thing that lets you write [regex] instead of [System.Text.RegularExpressions.Regex], and they save a lot of typing, but in order to keep the name space [...]]]></description>
			<content:encoded><![CDATA[	<p>Have I mentioned lately how much Oisin Grehan (a.k.a.: x0n) rocks?  <a href="http://www.nivot.org/2008/12/25/ListOfTypeAcceleratorsForPowerShellCTP3.aspx">He discovered</a> that in PowerShell 2 we can now define our own custom type accelerators.  A &#8220;Type Accelerator&#8221; is the thing that lets you write <code>[regex]</code> instead of <code>[System.Text.RegularExpressions.Regex]</code>, and they save a lot of typing, but in order to keep the name space clean, there aren&#8217;t very many of them predefined right now.</p>

	<p>Thanks to Oisin&#8217;s discovery, I&#8217;ve written a module to make it trivially easy to create your own custom type accelerators in PowerShell 2.  I&#8217;ll add a few more details here in the morning, and I&#8217;ll probably add a simulation of a &#8220;using&#8221; statement to the script (although you&#8217;ll practically never want to use it), but for now, here&#8217;s the script &#8230; the new CTP3 Get-Help will tell you everything you need to know.</p>

	<p><script type="text/javascript" src="http://PoshCode.org/embed/762"></script></p>

	<p>Maybe I should try that New-CommandBlogPost thing that James has been hawking over on the PowerShell team blog&#8230;</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powershell-2-ctp3-custom-accelerators-finally/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PoshCode Updated for CTP3</title>
		<link>http://huddledmasses.org/poshcode-updated-for-ctp3/</link>
		<comments>http://huddledmasses.org/poshcode-updated-for-ctp3/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 20:35:17 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Advanced Functions]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[PoshCode]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell Functions]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=930</guid>
		<description><![CDATA[I&#8217;ve updated the PoshCode script module to support CTP3, and added a -limit parameter to the Get-PoshCode cmdlet so you can specify how many items you want retrieved in the case where there are a lot of matches for your search terms &#8212; by default the limit is 25. Improvements to the underlying web search [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve updated the <a href="http://poshcode.org/PoshCode.psm1">PoshCode script module</a> to support CTP3, and added a -limit parameter to the Get-PoshCode cmdlet so you can specify how many items you want retrieved in the case where there are a lot of matches for your search terms &#8212; by default the limit is 25.</p>

	<h3>Improvements to the underlying web search <span class="caps">API</span></h3>

	<p>You’ve always been able to pass a <span class="caps">LIST</span> parameter to the <span class="caps">API</span>, and get more results by specifying a higher number. But it never worked with the &#8220;path&#8221; notation (until now).</p>

	<p>That is, you used to be able to do:</p>

	<ul>
		<li>http://poshcode.org/api1?q=start&#038;list=10</li>
	</ul>
	<ul>
		<li>http://poshcode.org/api1?q=start&#038;list=100</li>
	</ul>

	<p>To make the <span class="caps">API</span> a little easier to use I’ve enhanced it just now:</p>

	<ol>
		<li>You can now page the search results. </li>
		<li>You can use the word &#8220;limit&#8221; instead of &#8220;list&#8221;</li>
		<li>If you specify limit=0 (or list=0) I’ll give you everything I’ve got.  Please use a little precaution about that, as it could be a <span class="caps">LOT</span> of data. I’d much rather you retrieve, say … 25, and then get the second page if you want more.</li>
	</ol>
	<ol>
		<li>You can use path notation.</li>
	</ol>

	<p>So, you can use any of these URLs:</p>

	<ul>
		<li>http://poshcode.org/api1/start/list/25/page/1</li>
		<li>http://poshcode.org/api1/start/limit/25/page/2</li>
		<li>http://poshcode.org/api1?q=start&#038;list=25&#038;page=3</li>
	</ul>
	<ul>
		<li>http://poshcode.org/api1?q=start&#038;limit=25&#038;page=4</li>
	</ul>

	<p>There are a lot of search results for &#8220;start&#8221; ... feel free to play with enhancing the PoshCode module, or incorporating this into your apps, etc.</p>

	<p> <img src='http://huddledmasses.org/wordpress/wp-includes/' alt='[new]' class='wp-smiley' />  I should add that you don&#8217;t <em>have</em> to specify the limit or page number.  By default you&#8217;ll get the first 10 items, which should be enough.  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/poshcode-updated-for-ctp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2 CTP3 &#8211; First Impressions</title>
		<link>http://huddledmasses.org/powershell-2-ctp3-first-impressions/</link>
		<comments>http://huddledmasses.org/powershell-2-ctp3-first-impressions/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 05:55:36 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=925</guid>
		<description><![CDATA[Changes of particular interest Get-Command returns functions By default Get-Command used to return only apps, scripts in your path, and cmdlets&#8230; The new CTP3 default invocation includes functions. This is mostly a recognition of the increased power of functions with the arrival of that advanced function features (formerly known as script cmdlets). Advanced Functions Advanced [...]]]></description>
			<content:encoded><![CDATA[	<h2>Changes of particular interest</h2>

	<h3>Get-Command returns functions</h3>

	<p>By default <code>Get-Command</code> used to return only apps, scripts in your path, and cmdlets&#8230; The new CTP3 default invocation includes functions.  This is mostly a recognition of the increased power of functions with the arrival of that advanced function features (formerly known as script cmdlets).</p>

	<h3>Advanced Functions</h3>

	<p>Advanced Functions is the new name for what was called &#8220;Script Cmdlets&#8221; in CTP2.  Instead of adding a <code>CMDLET</code> keyword to the language, we now have a <code>[CmdletBinding()]</code> attribute which can be specified in your functions &#8212;just before the <code>PARAM</code> block&#8212; which will enable all of the features which were exclusive to CMDLETs in CTP2. <span class="em1">NOTE:</span> Unlike in C#, the parentheses in <code>[CmdletBinding()]</code> are <strong>REQUIRED</strong> to differentiate it from PowerShell&#8217;s type notation. </p>

	<p>I will write an entire article about Advanced Functions soon, because there is a lot to write about, and after struggling with them for several hours today, it&#8217;s clear that the about *  documentation for them is mostly wrong and misleading. The <a href="http://blogs.msdn.com/powershell/archive/2008/12/23/advanced-functions-and-test-leapyear-ps1.aspx">PowerShell team blog post about Advanced Functions</a> has some <em>working</em> examples, so start there and in the <a href="http://cli.gs/Posh2Ctp3ReadMe">release notes</a> (none of the about_functions_advanced samples will run &#8212; I wrote <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=389372&#38;amp;SiteID=99">a bug</a> about this, please vote for it if you agree).</p>

	<h3>Functions have help!</h3>

	<p>This is, without a doubt, my favorite feature so far.  You can embed help for functions in comments inside the function block, and Get-Help will find and parse it.  Not only that, but your functions get automatic implementation of the -? parameter, bringing script functions closer to equality with compiled cmdlets, in terms of user experience.</p>

	<h3>Cmdlet name collisions</h3>

	<p>You can now have two snapins or modules loaded which export the same cmdlets (or different ones with the same name).  PowerShell resolves to the last one loaded by default.  You can run previously loaded ones that have been hidden by specifying the full namespace\cmdlet path.</p>

	<h3>Modules</h3>

	<p>There has been a complete refactoring of the module system such that the environment variable and default Module folders have been renamed, and the cmdlets as well (Add-Module becomes Import-Module and New-Module). The &#8220;Module Metadata&#8221; support has been finished, so you can create .psd1 metadata files which wrap modules and expose additional features.  Thanks to the data in those Metadata files, Get-Module now returns much more information about modules, including the author&#8217;s name, copyright info, etc.  This is another area where I&#8217;ll have a whole article about the new functionality up soon, as an update to my <a href="http://huddledmasses.org/powershell-modules/">former article about modules</a>.</p>

	<h3>Lots of other things  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=';)' class='wp-smiley' /> </h3>

	<p>It&#8217;s not my intention to rewrite the release notes here&#8230; I just wanted to call attention to some of the stuff that&#8217;s most interesting to me.  You should definitely read <a href="http://cli.gs/Posh2Ctp3ReadMe">the release notes</a></p>

	<h2>Other improvements</h2>

	<h3>Eventing</h3>

	<p>In a sense, we had PSEvents in CTP2.  But in this release they&#8217;ve been beefed up, renamed a little, and are become a very useful way for cmdlet authors to expose functionality (you can create your own system-level events which users can write scripts to handle and target).</p>

	<h3>Exception Handling</h3>

	<p>I&#8217;m not really sure this counts as improved over CTP2, but a lot of people seem to be unaware that PowerShell v2 now supports the C#-like <code>try{ ... } catch { ... } finally { ... }</code> block, and allows you to specify multiple exceptions to be trapped by a single catch statement (I wish C# would implement that).</p>

	<h2>Command-line Parameters</h2>

	<p>There are two new parameters to PowerShell: </p>

	<h3><code>-WindowStyle</code> </h3>

	<p>This lets you execute PowerShell &#8220;Hidden&#8221; or at least &#8220;Minimized&#8221; so that your startup or scheduled tasks don&#8217;t need to pop up windows that interrupt the user! Hurray! In fact, not only can you launch PowerShell hidden, you can hide the running host window by just running a PowerShell instance in it (it stays hidden even after PowerShell exits &#8212; that might be considered a bug, but I&#8217;m not really sure what I think of it).  This would be most useful if you were trying to do <span class="caps">GUI</span> stuff in your scripts, but I&#8217;m sure you can think of other uses&#8230; here&#8217;s an example (IAA= is just a space, encoded).</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #003366; font-weight: bold;">powershell</span> <span style="color: #000066;">-win</span> hidden <span style="color: #000066;">-nop</span> <span style="color: #000066;">-enc</span> IAA<span style="color: #66cc66;">=</span><br />
<span style="color: #666666; font-style: italic;">## any output here won't be seen ...</span><br />
<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Reflection.<span style="color: #003366;">Assembly</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">LoadWithPartialName</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;System.Windows.Forms&quot;</span><span style="color: #333;">&#41;</span><br />
<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Windows.<span style="color: #003366;">Forms</span>.<span style="color: #003366;">MessageBox</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">Show</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;Hello from PowerShell&quot;</span>,<span style="color: #660033; font-weight: bold;">$pd</span><span style="color: #333;">&#41;</span><br />
<span style="color: #0066cc; font-style: italic;">write-<span style="font-style: normal;">host</span></span> <span style="color: #009900;">&quot;Hello&quot;</span> <span style="color: #000066;">-back</span> Green; <br />
<span style="color: #0066cc; font-style: italic;">Clear-<span style="font-style: normal;">Host</span></span><br />
<span style="color: #666666; font-style: italic;">## but this output will be, once the window returns...</span><br />
<span style="color: #0066cc; font-style: italic;">write-<span style="font-style: normal;">host</span></span> <span style="color: #009900;">&quot;And now back to your regularly scheduled program...&quot;</span> <span style="color: #000066;">-fore</span> Green; <br />
<span style="color: #003366; font-weight: bold;">powershell</span> <span style="color: #000066;">-win</span> normal <span style="color: #000066;">-nop</span> <span style="color: #000066;">-enc</span> IAA<span style="color: #66cc66;">=</span><br />
&nbsp;</div>

	<p>It even works in DOS:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #003366; font-weight: bold;">powershell</span> <span style="color: #000066;">-win</span> hidden <span style="color: #000066;">-nop</span> <span style="color: #000066;">-enc</span> IAA<span style="color: #66cc66;">=</span><br />
; any output here won<span style="color: #009900;">'t be seen ...<br />
echo &quot;Hello World!&quot;<br />
cls<br />
; and this will be...<br />
dir /w<br />
powershell -win normal -nop -enc IAA=<br />
</span></div>

	<h3><code>-ExecutionPolicy</code> </h3>

	<p>You can override the ExecutionPolicy on the command line. This is <strong>very</strong> interesting (and rather worrying).  It&#8217;s my opinion that <em>this option completely breaks the Execution Policy system</em> because you don&#8217;t have to be elevated/administrator to use the flag. </p>

	<p>What I&#8217;m trying to say is that in a business environment, where users are not administrators on their own systems, this flag seems to allow users to ignore the administrator&#8217;s script execution policy, and even modify their default shortcuts to just start with whatever setting they prefer. Currently (in v1 and v2) the Set-ExecutionPolicy cmdlet requires administrative rights (and an elevated console, on Vista), but this commandline argument means that anyone can just run <code>PowerShell -EP Unrestricted</code> to get around that.  </p>

	<p>This seems to render the setting a lot less useful, since it only applies if the user doesn&#8217;t know they can override it, or if the setting is unrestricted enough that the user doesn&#8217;t feel constrained by it. My guess is that the <code>ExecutionPolicy</code> parameter should either disappear, or be constrained to making the policy <strong>more</strong> restrictive than the default. Here&#8217;s my scary batch/vbs script: </p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #003366; font-weight: bold;">powershell</span> <span style="color: #000066;">-ex</span> unrestricted <span style="color: #000066;">-win</span> hidden <span style="color: #000066;">-com</span> <span style="color: #333;">&#123;</span>imo FileTransfer; <span style="color: #0066cc; font-style: italic;">new-<span style="font-style: normal;">filetransfer</span></span> http:<span style="color: #66cc66;">//</span>jaykul.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>pwn.<span style="color: #003366;">ps1</span> <span style="color: #660033; font-weight: bold;">$Env</span>:Temp\pwn.<span style="color: #003366;">ps1</span>; <span style="color: #66cc66;">&amp;</span>amp; <span style="color: #660033; font-weight: bold;">$Env</span>:Temp\pwn.<span style="color: #003366;">ps1</span><span style="color: #333;">&#125;</span></div>

	<p>If you have an opinion, <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=389489&#38;amp;SiteID=99">vote here</a></p>

	<h2>Possible bugs?</h2>

	<h3>[char] comparisons are supposed to be alphabetical</h3>

	<p>Formerly, comparisons of objects of type [char] (characters) were done as integers (against the unicode character value), but in CTP3 characters are supposed to behave as text, basically the same way strings do when it comes to case-insensitive comparison (except that, to keep them compatible, you must specify -<span class="caps">IEQ</span> to compare insensitive). This works fine in a case like: <code>([char]&#39;a&#39;) -ieq &#39;A&#39;</code> but inexplicably fails for <code>([char]&#39;a&#39;) -ieq ([char]&#39;A&#39;)</code> &#8230; which leads me to believe the team has simply hard-coded an exception for the CHAR-to-<span class="caps">STRING</span> comparison, and missed CHAR-to-<span class="caps">CHAR</span>. I <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=389470&#38;amp;SiteID=99">wrote that up</a> too, and hope you&#8217;ll take the time to agree or disagree (a couple of people in <span class="caps">IRC</span> mentioned that after this strangeness they just want it back the way it was).</p>

	<p>I&#8217;m sure I&#8217;ll have more to write here tomorrow &#8230;</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powershell-2-ctp3-first-impressions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Still waiting &#8230;</title>
		<link>http://huddledmasses.org/still-waiting-for-psh-ctp3/</link>
		<comments>http://huddledmasses.org/still-waiting-for-psh-ctp3/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 16:03:53 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[HttpRest]]></category>
		<category><![CDATA[Impatience]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/still-waiting/</guid>
		<description><![CDATA[EDIT: We found out this evening that it was suppose to ship tomorrow, but isn&#8217;t going to anymore because they heard about a (possible) bug and are delaying release to investigate (and fix it). while&#40;$true&#41;&#123; &#160; $items = Invoke-Http get http://www.microsoft.com/downloads/Results.aspx @&#123;freetext=&#34;powershell&#34;; nr=50; sortCriteria=&#34;date&#34;&#125; &#124; &#160; &#160; Receive-Http xml &#34;//*[@id='results']/table/tr/td/p/a&#34; &#124; &#160; &#160; where &#123;$_.&#34;#text&#34;&#125; [...]]]></description>
			<content:encoded><![CDATA[	<p> <img src='http://huddledmasses.org/wordpress/wp-includes/' alt='[new]' class='wp-smiley' />  <strong>EDIT</strong>: We found out this evening that it was suppose to ship tomorrow, but isn&#8217;t going to anymore because they heard about a (possible) bug and are delaying release to investigate (and fix it).</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #666699; font-weight: bold;">while</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$true</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span><br />
&nbsp; <span style="color: #660033; font-weight: bold;">$items</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Invoke-<span style="font-style: normal;">Http</span></span> get http:<span style="color: #66cc66;">//</span>www.<span style="color: #003366;">microsoft</span>.<span style="color: #003366;">com</span><span style="color: #66cc66;">/</span>downloads<span style="color: #66cc66;">/</span>Results.<span style="color: #003366;">aspx</span> @<span style="color: #333;">&#123;</span>freetext<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;powershell&quot;</span>; nr<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">50</span>; sortCriteria<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;date&quot;</span><span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span> <br />
&nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Receive-<span style="font-style: normal;">Http</span></span> <span style="color: #003366; font-weight: bold;">xml</span> <span style="color: #009900;">&quot;//*[@id='results']/table/tr/td/p/a&quot;</span> <span style="color: #66cc66;">|</span><br />
&nbsp; &nbsp; <span style="color: #660033;">where</span> <span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #009900;">&quot;#text&quot;</span><span style="color: #333;">&#125;</span><br />
<br />
&nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$items</span>.<span style="color: #003366;">Count</span> <span style="color: #000066;">-gt</span> <span style="color: #cc66cc;">47</span> <span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Out-<span style="font-style: normal;">Voice</span></span> <span style="color: #009900;">&quot;There is a new PowerShell Release&quot;</span>;<br />
&nbsp; &nbsp; <span style="color: #660033;">Start</span> <span style="color: #009900;">&quot;http://www.microsoft.com/downloads/$($items[0].href)&quot;</span><br />
&nbsp; &nbsp; <span style="color: #666699; font-weight: bold;">throw</span> <span style="color: #009900;">&quot;Confetti&quot;</span><br />
&nbsp; <span style="color: #333;">&#125;</span> <br />
&nbsp; <span style="color: #660033;">sleep</span> <span style="color: #cc66cc;">30</span><br />
<span style="color: #333;">&#125;</span></div>

	<h4>Disclaimer: it wasn&#8217;t <em>really</em> my idea.  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=';)' class='wp-smiley' /> </h4>

	<p> <img src='http://huddledmasses.org/wordpress/wp-includes/' alt='[new]' class='wp-smiley' />  Edit: Someone suggested I should link to the required PoshCode scripts:</p>

	<ul>
		<li><a href="http://poshcode.org/691">Invoke-Http and Receive-Http</a> are in the <a href="http://huddledmasses.org/using-rest-apis-from-powershell-with-the-dream-sdk/">HttpRest</a> script</li>
		<li><a href="http://poshcode.org/111">Out-Voice</a></li>
	</ul>
	<ul>
		<li><a href="http://poshcode.org/741">Start</a> is originally from <a href="http://CodePlex.com/PowerShellCX">PSCX</a>"</li>
	</ul>

	<p>Wouldn&#8217;t it be cool to be able to &#8220;require&#8221; those like a ruby GEM?  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=';)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/still-waiting-for-psh-ctp3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

