&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Articles from October 2011 on PowerShell.org - Welcome Automaters!</title><link>https://powershell.org/articles/2011/10/</link><description>Recent content in Articles from October 2011 on PowerShell.org - Welcome Automaters!</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://powershell.org/articles/2011/10/index.xml" rel="self" type="application/rss+xml"/><item><title>Windows PowerShell Version 3 Simplified Syntax</title><link>https://powershell.org/articles/2011-10-19-windows-powershell-version-3-simplified-syntax/</link><guid>https://powershell.org/articles/2011-10-19-windows-powershell-version-3-simplified-syntax/</guid><pubDate>Thu, 20 Oct 2011 00:44:42 +0000</pubDate><description>&lt;p&gt;Windows PowerShell version 3 introduces a simplified syntax for the Where-Object and Foreach-Object cmdlets. The simplified syntax shown below, eliminates the curly braces as well as the need for the special variable $_.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\PS&amp;gt; Get-Process | Where PM -gt 100MB ... C:\PS&amp;gt; Get-Process | Foreach Name ... &lt;/code&gt;The intent of this &amp;ldquo;syntax&amp;rdquo; is to make it easier for folks get started with PowerShell. Compared to the commands below, I can see the value of the simplified syntax:&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Windows PowerShell version 3 introduces a simplified syntax for the Where-Object and Foreach-Object cmdlets. The simplified syntax shown below, eliminates the curly braces as well as the need for the special variable $_.</p><p><code>C:\PS&gt; Get-Process | Where PM -gt 100MB ... C:\PS&gt; Get-Process | Foreach Name ...</code>The intent of this &ldquo;syntax&rdquo; is to make it easier for folks get started with PowerShell. Compared to the commands below, I can see the value of the simplified syntax:</p><p><code>C:\PS&gt; Get-Process | Where {$_.PM -gt 100MB} ... C:\PS&gt; Get-Process | Foreach {$_.Name} ...</code>When folks are first learning PowerShell, the special variable $_ is one of those mental model hurdles they have to get over. The simplified syntax feature of V3 seems to generate a fair amount of controversy (is it really necessary, doesn"™t this just complicate things more, etc). Regardless of where you stand on the simplified syntax it is useful to understand how it works.</p><p>Given that it appears to be a simplified expression syntax you might think this required a change to the PowerShell parser"™s grammar but you would be wrong. It turns out that the simplified syntax is implemented by additional parameter sets &ldquo;“ lots of additional parameter sets. In fact, for every operator supported, there is an additional parameter set to support that operator. Let&rdquo;™s see this with the Where-Object cmdlet by listing out all of its parameter set names:</p><h2 id="name" class="ps-heading">`C:\PS&gt; Get-Command Where-Object | Select -Expand ParameterSets | Format-Table Name
Name<a class="ps-heading-anchor" href="#name" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h2><p>EqualSet
ScriptBlockSet
CaseSensitiveGreaterThanSet
CaseSensitiveNotEqualSet
LessThanSet
CaseSensitiveEqualSet
NotEqualSet
GreaterThanSet
CaseSensitiveLessThanSet
GreaterOrEqualSet
CaseSensitiveGreaterOrEqualSet
LessOrEqualSet
CaseSensitiveLessOrEqualSet
LikeSet
CaseSensitiveLikeSet
NotLikeSet
CaseSensitiveNotLikeSet
MatchSet
CaseSensitiveMatchSet
NotMatchSet
CaseSensitiveNotMatchSet
ContainsSet
CaseSensitiveContainsSet
NotContainsSet
CaseSensitiveNotContainsSet
InSet
CaseSensitiveInSet
NotInSet
CaseSensitiveNotInSet
IsSet
IsNotSet
`Most of these correspond to the operators you are already familiar with such as: &ldquo;“GT, &ldquo;“LT, &ldquo;“GE, &ldquo;“LE, &ldquo;“LIKE, &ldquo;“MATCH, &ldquo;“NOTMATCH, &ldquo;“CONTAINS, &ldquo;“NOTCONTAINS, etc. Note however there are two new operators in PowerShell V3: &ldquo;“In and &ldquo;“NotIn which you can use like so:</p><p><code>C:\PS&gt; 1 -In 1..10 True C:\PS&gt; 20 -NotIn 1..10 True</code>Let&rdquo;™s look at the interesting parameters on these operator specific parameter sets. Let&rdquo;™s look at the EqualsSet parameter set:</p><p>`C:\PS&gt; Get-Command Where-Object | Select -Expand ParameterSets | Where Name -eq EqualSet |
Select -Expand Parameters | Where Position -ge 0 |
Format-Table Name,Position,IsMandatory -AutoSize
Name Position IsMandatory</p><hr><p>Property 0 True
Value 1 False
`As it turns out, these results are the same for all the<em>operator</em> oriented parameter sets. At the very minimum, the Property parameter is required and is always the first positional parameter. And as you would expect, if you don&rdquo;™t provide it, you get prompted for a value:</p><p><code>C:\PS&gt; Get-Process | Where -eq cmdlet Where-Object at command pipeline position 2 Supply values for the following parameters: Property:</code>Now even though Value parameter is specified as not mandatory, in many cases if you don&rdquo;™t provide it you will get a terminating error e.g.:</p><p>`C:\PS&gt; Get-Process | Where Name -eq
Where-Object : The specified operator requires both the -Property and -Value parameters. Supply both parameters and
retry.
At line:1 char:15</p><ul><li>Get-Process | Where Name -eq</li><li><pre><code> ~~~~~~~~~~~~~~</code></pre><ul><li>CategoryInfo : InvalidArgument: (:) [Where-Object], PSArgumentException</li><li>FullyQualifiedErrorId : ValueNotSpecifiedForWhereObject,Microsoft.PowerShell.Commands.WhereObjectCommand
`There are some cases where you don&rdquo;™t have to provide the value nor the operator e.g.:</li></ul></li></ul><p>`C:\PS&gt; Get-Process | Where Responding
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName</p><hr><pre><code>216 10 3560 2896 73 4000 atieclxx
130 7 2380 1028 33 1020 atiesrxx
157 11 17288 13344 49 7876 audiodg
28 6 1256 420 42 0.06 2752 BluetoothHeadsetProxy</code></pre><p>&hellip;
`This works because A) the EqualsSet parameter set is the default parameter set and B) the Where-Object implementation appears to coerce the property specified (<em>Responding</em> in this case) to Boolean. If the result is $true then the object is output by Where-Object and sent on its way down the pipeline.</p><p>So all this simplified syntax really is, is a bunch of operator specific parameter sets on Where-Object that have a positional and mandatory Property parameter of type [string] and a positional Value parameter of type [object]. In the case of Foreach-Object it is one extra parameter set called PropertyAndMethodSet which has one mandatory, positional parameter called MemberName. And as with any cmdlet, you provide the parameter values and the cmdlet determines how to interpret them. In fact, given standard parameter parsing behavior the below is as valid as the conventional notation:</p><p><code>C:\PS&gt; Get-Process | Where -GT PM 100MB ... C:\PS&gt; Get-Process | Where PM 100MB -GT ... C:\PS&gt; Get-Process | Where -Value 100MB -Property PM -GT ...</code>Now where this syntax can lead you astray if you don&rdquo;™t understand how it works, is if you make the assumption that this is a parsed expression. In that case, folks might expect this to work:</p><p><code>C:\PS&gt; Get-Process | Where Threads.Count -GT 100</code>There<em>is</em> a Threads collection on each Process object. We might think that we can access a property on that collection but in effect, what happens is that the Where-Object Property parameter gets the value &ldquo;Threads.Count&rdquo; and there is no property on a Process object called &ldquo;Threads.Count&rdquo;. This silently fails which might lead you to believe there are no processes with greater than 100 threads. But reverting back to the standard syntax we see that isn&rdquo;™t the case:</p><p>`C:\PS&gt; Get-Process | Where {$_.Threads.Count -GT 100}
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName</p><hr><p>2080 126 155680 139928 531 113.68 4920 msnmsgr
1087 0 312 8800 15 4 System
`So when you are using the simplified syntax be sure to keep in mind that you can **only **specify property names and you cannot access sub-properties. Keep your property names simple and you should be copasetic with the new, simplified syntax. While I&rdquo;™m a little unsure about the new simplified syntax given how quickly you can fall off the &ldquo;simple&rdquo; path into the sharp rocks and lava below, I will say this. As I wrote this blog post, I used the simplified syntax quite a bit and I have to say that it is growing on me.</p><p>One final item to mention about simplified syntax. It turns out that some folks have a hard time grokking $_ but when they&rdquo;™re presented with<strong>$PSItem</strong> it apparently makes more sense to them. So in PowerShell v3, wherever you can use $_ you can also use $PSItem. $PSItem is not an alias. It seems to be a duplicate variable defined in all the same scopes as $_ and its value tracks that of $_ e.g.:</p><p>`C:\PS&gt; 1 | Foreach {Get-Variable<em>,psitem; $</em> = 4; Get-Variable _,psitem}
Name Value</p><hr><p>_ 1
PSItem 1
_ 4
PSItem 4
`<a href="http://feeds.wordpress.com/1.0/gocomments/rkeithhill.wordpress.com/233/"><img src="http://feeds.wordpress.com/1.0/comments/rkeithhill.wordpress.com/233/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=rkeithhill.wordpress.com&amp;blog=18780344&amp;%23038;post=233&amp;%23038;subd=rkeithhill&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>PowerSE 2.5.3 is now available</title><link>https://powershell.org/articles/2011-10-14-powerse-2-5-3-is-now-available/</link><guid>https://powershell.org/articles/2011-10-14-powerse-2-5-3-is-now-available/</guid><pubDate>Fri, 14 Oct 2011 15:02:05 +0000</pubDate><description>&lt;p&gt;A little over a week ago we released &lt;a href="http://powerwf.com/products/powerse.aspx"&gt;PowerSE 2.5.3&lt;/a&gt; to the web.  You can download the latest release &lt;a href="http://powerwf.com/products/powerse.aspx"&gt;here&lt;/a&gt;.  This release includes many great improvements to the &lt;a href="http://powerwf.com/products/powerse.aspx"&gt;PowerSE&lt;/a&gt; product, many of which were requested by you, so thanks for your feedback and please keep it coming!&lt;/p&gt;
&lt;h4 id="no-time-limit-for-freeware" class="ps-heading"&gt;No time limit for freeware&lt;a class="ps-heading-anchor" href="#no-time-limit-for-freeware" aria-label="Link to this section" title="Link to this section"&gt;&lt;i class="fas fa-link" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;With this release, we&amp;quot;™ve removed the requirement to re-download this product every 60 days.  This was our number one feature request since we made &lt;a href="http://powerwf.com/products/powerse.aspx"&gt;PowerSE&lt;/a&gt; a freeware product.  Now when you download &lt;a href="http://powerwf.com/products/powerse.aspx"&gt;PowerSE&lt;/a&gt; 2.5.3, it is truly freeware and you can use it as long as you like!&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A little over a week ago we released<a href="http://powerwf.com/products/powerse.aspx">PowerSE 2.5.3</a> to the web.  You can download the latest release<a href="http://powerwf.com/products/powerse.aspx">here</a>.  This release includes many great improvements to the<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> product, many of which were requested by you, so thanks for your feedback and please keep it coming!</p><h4 id="no-time-limit-for-freeware" class="ps-heading">No time limit for freeware<a class="ps-heading-anchor" href="#no-time-limit-for-freeware" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>With this release, we"™ve removed the requirement to re-download this product every 60 days.  This was our number one feature request since we made<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> a freeware product.  Now when you download<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> 2.5.3, it is truly freeware and you can use it as long as you like!</p><h4 id="powervi-integration" class="ps-heading">PowerVI Integration<a class="ps-heading-anchor" href="#powervi-integration" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>Since<a href="http://powerwf.com/products/powerscripter.aspx">PowerVI</a> has joined the Devfarm family of products, we have now improved the integration between<a href="http://powerwf.com/products/powerscripter.aspx">PowerVI</a> and<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> and<a href="http://powerwf.com/products/powerwf.aspx">PowerWF</a>. This enables easier authoring and testing of VMware automation scripts and workflows before you publish them to be integrated in the vSphere client, and it highlights one of the greatest values of the Devfarm products &ldquo;“ the rich integration between them that make everything much easier.</p><h4 id="tabs-to-spaces-support" class="ps-heading"><strong>Tabs to spaces support</strong><a class="ps-heading-anchor" href="#tabs-to-spaces-support" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>We&rdquo;™ve added support for configuring how tabs are used in the<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> Script Editor.  If you want spaces inserted when you press the Tab key while editing scripts, all you need to do is to set $psise.Settings.AutoConvertTabsToSpaces to $true in the embedded console.  If you want the tab size to be something other than the default value of 4, you simply set $psise.Settings.TabSize to the number of spaces you want to use for tab characters.  These only need to be set once, so you can simply make the calls in the embedded console and then you"™ll always have it configured that way going forward.</p><h4 id="enhanced-history-pane" class="ps-heading">Enhanced history pane<a class="ps-heading-anchor" href="#enhanced-history-pane" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>The history pane in<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> has always been useful, but now it"™s much better!  With the history pane in<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> 2.5.3, you can identify which commands were successful and which were not, all at a glance by looking at the icon.  You can also tell which commands were allowed to run to completion and which were cancelled.  Most importantly, you can identify the duration of any command that you run, so if you are trying to get the most performance from your scripts, this is an easy way to compare the performance for several related commands so that your scripts run as fast as they can.</p><h4 id="greatly-improved-support-for-international-environments" class="ps-heading">Greatly improved support for international environments<a class="ps-heading-anchor" href="#greatly-improved-support-for-international-environments" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>In previous releases of<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a>, there were a number of defects preventing international keyboard layouts (i.e. those other than &ldquo;US English&rdquo;) from working properly in the embedded console.  Those defects have been fixed, so now you can use the embedded console with international keyboards just fine.</p><p>We also added support for Unicode characters to the embedded console, making it easier for customers to get the output they expect regardless of where they happen to be.</p><h4 id="multi-select-support-in-the-fileopen-dialog" class="ps-heading">Multi-select support in the File|Open dialog<a class="ps-heading-anchor" href="#multi-select-support-in-the-fileopen-dialog" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>With<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> 2.5.3, you can open multiple files in one folder at once by simply selecting the files you want before you click on the Open button.  This can be a big timesaver when you are working with modules containing many files!</p><h4 id="smarter-variable-intellisense" class="ps-heading">Smarter variable Intellisense<a class="ps-heading-anchor" href="#smarter-variable-intellisense" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>When you enter a variable name in a script, it can be difficult to determine if you are entering the name of an existing variable or if you are creating a new variable.  Previous releases would sometimes complete a variable name incorrectly when you were in fact creating a new variable name.  This shouldn"™t be a problem any longer, because we now allow you to enter new variable names and the auto-completion should only happen when you want it to happen.</p><h4 id="proper-ps1xml-file-support" class="ps-heading">Proper ps1xml file support<a class="ps-heading-anchor" href="#proper-ps1xml-file-support" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>In<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> 2.5.3, if you are working with ps1xml files, you will now get proper Intellisense as well as auto-completion of xml elements as you would expect.</p><h4 id="fast-clearing-of-the-embedded-console-window" class="ps-heading">Fast clearing of the embedded console window<a class="ps-heading-anchor" href="#fast-clearing-of-the-embedded-console-window" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>In today"™s era of PowerShell, we all want to do more in less time, so much so that even typing in cls in the embedded console and pressing Enter can be cumbersome when you do it repeatedly. <a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> 2.5.3 allows you to clear the embedded console window at any time by simply pressing Ctrl+Del.</p><h4 id="and-more" class="ps-heading">And more"¦<a class="ps-heading-anchor" href="#and-more" aria-label="Link to this section" title="Link to this section"><i class="fas fa-link" aria-hidden="true"/></a></h4><p>This is just a short list of some of the key changes we have made in this release.  There are others that I want to talk about, but I"™m going to save a few for follow-up blog posts.  We"™ve been spending a lot of time on<a href="http://powerwf.com/products/powerse.aspx">PowerSE</a> recently, and between our hard work and your great feedback, we"™ve built a fantastic, best-in-class PowerShell script editor!  If you write PowerShell scripts, I encourage you to give this release a try, and be sure to let us know what you think!  Also, if you have any questions, feel free to leave me a note on my blog or pop over to<a href="http://www.devfarm.com/">www.devfarm.com</a> and ask us directly in the chat window.  We"™re always listening!</p><p>Thanks,</p><p>Kirk out.</p><p>Technorati Tags:<a href="http://technorati.com/tags/PowerShell">PowerShell</a>,<a href="http://technorati.com/tags/PoSh">PoSh</a>,<a href="http://technorati.com/tags/PowerSE">PowerSE</a>,<a href="http://technorati.com/tags/PowerWF">PowerWF</a>,<a href="http://technorati.com/tags/PowerVI">PowerVI</a>,<a href="http://technorati.com/tags/Devfarm">Devfarm</a></p><p><a href="http://feeds.wordpress.com/1.0/gocomments/kirkmunro.wordpress.com/717/"><img src="http://feeds.wordpress.com/1.0/comments/kirkmunro.wordpress.com/717/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=poshoholic.com&amp;blog=1436967&amp;%23038;post=717&amp;%23038;subd=kirkmunro&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item></channel></rss>