<?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; Releases</title>
	<atom:link href="http://huddledmasses.org/tag/releases/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<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>
	</channel>
</rss>

