<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IT Pro PowerShell experience</title>
	<atom:link href="http://becomelotr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://becomelotr.wordpress.com</link>
	<description>Share what I know or discovered when working with Windows PowerShell.</description>
	<lastBuildDate>Wed, 15 Feb 2012 22:41:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='becomelotr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>IT Pro PowerShell experience</title>
		<link>http://becomelotr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://becomelotr.wordpress.com/osd.xml" title="IT Pro PowerShell experience" />
	<atom:link rel='hub' href='http://becomelotr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Case sensitive ValidateSet.</title>
		<link>http://becomelotr.wordpress.com/2012/01/31/case-sensitive-validateset/</link>
		<comments>http://becomelotr.wordpress.com/2012/01/31/case-sensitive-validateset/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 11:40:56 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[quick tip]]></category>
		<category><![CDATA[Scripting Techniques]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/?p=138</guid>
		<description><![CDATA[OK, I know it may be useless in 99% of cases, but lets say you fall in the 1%. You not only care about the string itself, but also about case used. E.g. you don’t want user to pollute produced &#8230; <a href="http://becomelotr.wordpress.com/2012/01/31/case-sensitive-validateset/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=138&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK, I know it may be useless in 99% of cases, but lets say you fall in the 1%. You not only care about the string itself, but also about case used. E.g. you don’t want user to pollute produced objects with scary thing like: lApToP. What can you do?</p>
<p>So far I was sure only combination of ValidateSet and ValidatePattern could make it possible. And due to default regex behaviour in PowerShell – it would be complicated even there (need to explicitly disable IgnoreCase option also in regex pattern):</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#8a2be2;">Get-Foo</span> <span style="color:#000000;">{</span>
<span style="color:#00008b;">param</span> <span style="color:#000000;">(</span>
    <span style="color:#a9a9a9;">[</span><span style="color:#00bfff;">ValidateSet</span><span style="color:#000000;">(</span><span style="color:#8b0000;">'laptop'</span><span style="color:#a9a9a9;">,</span><span style="color:#8b0000;">'desktop'</span><span style="color:#000000;">)</span><span style="color:#a9a9a9;">]</span>
    <span style="color:#a9a9a9;">[</span><span style="color:#00bfff;">ValidatePattern</span><span style="color:#000000;">(</span><span style="color:#8b0000;">'(?-i:^[a-z]+$)'</span><span style="color:#000000;">)</span><span style="color:#a9a9a9;">]</span>
    <span style="color:#008080;">[string]</span><span style="color:#ff4500;">$Type</span>
<span style="color:#000000;">)</span>
    <span style="color:#ff4500;">$Type</span>
<span style="color:#000000;">}</span></pre>
<p>That would work, obviously. But recently I was reading docs for other Validate* class on MSDN, and out of curiosity I selected <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms714434(v=vs.85).aspx">ValidateSet</a>. And what I found? There is named option in it, IgnoreCase, that defaults to true. At first I could not figure out how to use it and set to false. Than I compared it with other attribute declarations and syntax for named parameters for those within PowerShell, like <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms714420(v=vs.85).aspx">CmdletBinding</a> (plenty of named parameters there). And because I use those in PowerShell a lot it was easy to translate the one in ValidateSet:</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#8a2be2;">Get-Bar</span> <span style="color:#000000;">{</span>
<span style="color:#00008b;">param</span> <span style="color:#000000;">(</span>
    <span style="color:#a9a9a9;">[</span><span style="color:#00bfff;">ValidateSet</span><span style="color:#000000;">(</span><span style="color:#8b0000;">'laptop'</span><span style="color:#a9a9a9;">,</span><span style="color:#8b0000;">'desktop'</span><span style="color:#a9a9a9;">,</span><span style="color:#000000;">IgnoreCase</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$false</span><span style="color:#000000;">)</span><span style="color:#a9a9a9;">]</span>
    <span style="color:#008080;">[string]</span><span style="color:#ff4500;">$Type</span>
<span style="color:#000000;">)</span>
    <span style="color:#ff4500;">$Type</span>
<span style="color:#000000;">}</span></pre>
<p>It was not documented in PowerShell itself (or: I was not able to spot it in the help anywhere), so I thought it might be worth sharing. <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2012/01/wlemoticon-winkingsmile.png?w=584" /> Just in case someone need it. I know I did and eventually added enum class to support this…</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=138&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2012/01/31/case-sensitive-validateset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2012/01/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell vNext: AST.</title>
		<link>http://becomelotr.wordpress.com/2011/12/19/powershell-vnext-ast/</link>
		<comments>http://becomelotr.wordpress.com/2011/12/19/powershell-vnext-ast/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 23:27:07 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Parser]]></category>
		<category><![CDATA[V3]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/?p=134</guid>
		<description><![CDATA[What is that? There is one addition in PowerShell vNext that I look really forward to. In v2 we have parser available. It makes work with PowerShell code easier. But PowerShell team haven’t stopped there. AST (Abstract Syntax Tree) is &#8230; <a href="http://becomelotr.wordpress.com/2011/12/19/powershell-vnext-ast/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=134&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>What is that?</h1>
<p>There is one addition in PowerShell vNext that I look really forward to. In v2 we have parser available. It makes work with PowerShell code easier. But PowerShell team haven’t stopped there. <strong>AST (Abstract Syntax Tree)</strong> is new concept (at least – to me) and it makes parsing code more interesting: instead of stream of tokens (which is still there with AST and is also more accurate than v2 precedents) we get tree of syntax: from Script to single Statement. Browsing thru that tree may be very hard at first. I tried to use view that seems natural for that kind of complex structures: Format-Custom. The problem that I went into was the fact, that each AST contains “Extent” and “Parent” property. And those properties keep whole code which makes Format-Custom lengthy and impractical. So my first step was to create .ps1xml files to make format and object themselves bit different. I hidden two properties I think are not very useful. You can still access them using psbase on each object – and that exactly the information you get if you try to access them directly. Next step I took was to create simple function that would wrap .NET call to System.Management.Automation.Language.Parser static methods (ParseInput, ParseFile) and make use of them more natural and PowerShell-ish. Then I packed it all in the module, so that I could paste it somewhere and let others use it and complain about things I did wrong (like using global scope to store tokens/ errors).</p>
<h1>How would I use it?</h1>
<p>Parser is the way to look closer at your code. If you want to extend editors of your choice (ISE, PowerGUI Script Editor, or any other you like and use) than having ability to read code as PowerShell does makes some operations more error-prone. It was the case with tokens in v2 – but it’s more the case with addition of AST in v3. Now you know exactly where you are, and you know what to expect. What language elements are justified in current AST, and which are wrong. When I was playing with new stuff I noticed, that it’s not replacement (as far as I can tell) for “old” technique. It’s just extension to it. But I’m not sure if that’s actually the case – it’s probable that I’m missing something obvious. For example: new tokens do not contain any info about absolute position in a script. On the other hand – being able to read nested tokens makes some operations easier (e.g. expanding aliases in sub-expression within a string). Example:</p>
<pre class="PowerShellColorizedScript"><span style="color:#ff4500;">$Script</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">@'
&quot;$($Foo.Count)&quot;
'@</span>             

<span style="color:#ff4500;">$AST</span> <span style="color:#a9a9a9;">=</span> <span style="color:#0000ff;">Get-AST</span> <span style="color:#000080;">-InputScript</span> <span style="color:#ff4500;">$Script</span> <span style="color:#000080;">-TokensList</span> <span style="color:#8a2be2;">TK</span>            

<span style="color:#0000ff;">Write-Host</span> <span style="color:#8a2be2;">New</span> <span style="color:#8a2be2;">tokens</span> <span style="color:#8a2be2;">-</span> <span style="color:#8a2be2;">nested</span> <span style="color:#8a2be2;">tokens</span>
<span style="color:#ff4500;">$TK</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">where</span> <span style="color:#000000;">{</span> <span style="color:#ff4500;">$_</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">NestedTokens</span> <span style="color:#000000;">}</span> <span style="color:#a9a9a9;">|</span>
    <span style="color:#0000ff;">Select</span> <span style="color:#000080;">-ExpandProperty</span> <span style="color:#8a2be2;">NestedTokens</span>
<span style="color:#0000ff;">Write-Host</span> <span style="color:#8a2be2;">Old</span> <span style="color:#8a2be2;">tokens</span> <span style="color:#8a2be2;">-</span> <span style="color:#8a2be2;">no</span> <span style="color:#8a2be2;">info</span> <span style="color:#8a2be2;">of</span> <span style="color:#8a2be2;">nested</span> <span style="color:#8a2be2;">tokens</span> <span style="color:#8a2be2;">here</span>
<span style="color:#008080;">[Management.Automation.PSParser]</span><span style="color:#a9a9a9;">::</span><span style="color:#000000;">Tokenize</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$Script</span><span style="color:#a9a9a9;">,</span> <span style="color:#008080;">[ref]</span><span style="color:#ff4500;">$null</span><span style="color:#000000;">)</span></pre>
<h1>Where is this module?</h1>
<p>For now I’ve pasted it into <a href="http://gallery.technet.microsoft.com/AST-Module-eecb5a64">TechNet script gallery</a>. I would paste it into poshcode too, but because .psm1 file is just 1/3 of whole story I decided it makes no sense (yet). If you have some other ideas on what would be nice to have there – go ahead and change it, or let me know and I will try to do it. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile2.png?w=584" /> Would love to see others picking up this neat new concept. In my opinion in makes working with PowerShell code more natural – after all it is, in fact, more tree-like construct rather than flat stream of tokens. Having ability to see this tree structure up front may mean a lot to people who, like me, love PowerShell not only for it’s usability but also for the way it is built. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile2.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=134&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/12/19/powershell-vnext-ast/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile2.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile2.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>
	</item>
		<item>
		<title>Select groups of code in ISE.</title>
		<link>http://becomelotr.wordpress.com/2011/12/14/select-groups-of-code-in-ise/</link>
		<comments>http://becomelotr.wordpress.com/2011/12/14/select-groups-of-code-in-ise/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 00:15:44 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell ISE]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/?p=129</guid>
		<description><![CDATA[New(er) ISE comes with lots of cool features. One of them is group-matching in editor. This is more than expected from modern editor. But wouldn’t that be handy to have possibility to easily select whole group? If you put cursor &#8230; <a href="http://becomelotr.wordpress.com/2011/12/14/select-groups-of-code-in-ise/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=129&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>New(er) ISE comes with lots of cool features. One of them is group-matching in editor. This is more than expected from modern editor. But wouldn’t that be handy to have possibility to easily select whole group? If you put cursor at the border of group – matching charter will be highlighted to simplify job. But for me – that’s too much work. How about simple function that would select whole group for me?</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#8a2be2;">Select-Group</span> <span style="color:#000000;">{</span>
    <span style="color:#00008b;">if</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$Editor</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$psISE</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CurrentFile</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Editor</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
        <span style="color:#00008b;">if</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CanGoToMatch</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
            <span style="color:#ff4500;">$startLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$startColumn</span> <span style="color:#a9a9a9;">=</span>
                <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CaretLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CaretColumn</span>
            <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">GoToMatch</span><span style="color:#000000;">(</span><span style="color:#000000;">)</span>
            <span style="color:#ff4500;">$endLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$endColumn</span> <span style="color:#a9a9a9;">=</span>
                <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CaretLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CaretColumn</span>
            <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">GoToMatch</span><span style="color:#000000;">(</span><span style="color:#000000;">)</span>
            <span style="color:#006400;"># We can&amp;apos;t be sure caret was at beg of group...</span>
            <span style="color:#00008b;">if</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$startLine</span> <span style="color:#a9a9a9;">-gt</span> <span style="color:#ff4500;">$endLine</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
                <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Select</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$endLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$endColumn</span><span style="color:#a9a9a9;">,</span>
                    <span style="color:#ff4500;">$startLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$startColumn</span><span style="color:#000000;">)</span>
            <span style="color:#000000;">}</span> <span style="color:#00008b;">else</span> <span style="color:#000000;">{</span>
                <span style="color:#ff4500;">$Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Select</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$startLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$startColumn</span><span style="color:#a9a9a9;">,</span>
                    <span style="color:#ff4500;">$endLine</span><span style="color:#a9a9a9;">,</span> <span style="color:#ff4500;">$endColumn</span><span style="color:#000000;">)</span>
            <span style="color:#000000;">}</span>
        <span style="color:#000000;">}</span>
    <span style="color:#000000;">}</span>
<span style="color:#000000;">}</span></pre>
<p>Now all you have to do is assign hotkey to it and you can select groups at will. Enjoy! <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile1.png?w=584" /></p>
<p><strong>Update</strong>: quick tip needs quick update – forgot that sometimes (often?) group is all on one line, and column has to be checked in such scenario to avoid exception, so if clause that decides on $Editor.Select syntax should be a bit different:</p>
<pre class="PowerShellColorizedScript"><span style="color:#000000;">(</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$startLine</span> <span style="color:#a9a9a9;">-gt</span> <span style="color:#ff4500;">$endLine</span><span style="color:#000000;">)</span> <span style="color:#a9a9a9;">-or</span>
    <span style="color:#000000;">(</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$startLine</span> <span style="color:#a9a9a9;">-eq</span> <span style="color:#ff4500;">$endLine</span><span style="color:#000000;">)</span> <span style="color:#a9a9a9;">-and</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$startColumn</span> <span style="color:#a9a9a9;">-gt</span> <span style="color:#ff4500;">$endColumn</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span></pre>
<p>Hope now I haven’t missed any other important exception. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile1.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=129&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/12/14/select-groups-of-code-in-ise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile1.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile1.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>
	</item>
		<item>
		<title>CTP1 to CTP2 gotcha&#8230; :)</title>
		<link>http://becomelotr.wordpress.com/2011/12/03/ctp1-to-ctp2-gotcha/</link>
		<comments>http://becomelotr.wordpress.com/2011/12/03/ctp1-to-ctp2-gotcha/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 09:55:36 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/?p=126</guid>
		<description><![CDATA[Ok, CTP2 is out. This is a great news, and a lot of things to play. Newer ISE, finally fixed “killer TAB” in console, Update-Help that picks up data from network and more. There is one thing you need to &#8230; <a href="http://becomelotr.wordpress.com/2011/12/03/ctp1-to-ctp2-gotcha/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=126&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, <a href="http://blogs.msdn.com/b/powershell/archive/2011/12/02/windows-management-framework-3-0-community-technology-preview-ctp-2-available-for-download.aspx">CTP2 is out</a>. This is a great news, and a lot of things to play. Newer ISE, finally fixed “killer TAB” in console, Update-Help that picks up data from network and more.</p>
<p>There is one thing you need to be aware of: CTP1 and CTP2 both installed at the same time is a really bad idea. Trust me, you don’t want to see it (any command results in pages and pages of errors, tab does not work, highlighting syntax in ISE is total disaster).</p>
<p>So first thing: <strong>don’t do it</strong>. Uninstall CTP1 first. Documentation is clear about that and I know already why. <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile.png?w=584" /></p>
<p>But let’s say you did that mistake already. Information “you shouldn’t!” is not really helpful now, right? I went that path so I decided I would share. It’s nothing spectacular, all I did was:</p>
<ul>
<li>removed CTP2 (reboot)</li>
<li>installed CTP1 (reboot)</li>
<li>removed CTP1 (ignore the fact, that it may show up as CTP2 anyway – and yes, reboot)</li>
<li>install CTP2 on clean v2 and enjoy the show! <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile.png?w=584" /></li>
</ul>
<p>I would also double-check how it goes after each step (make sure CTP1 works, make sure clean v2 actually is clean). Hope it helps some other people who prefer to use things firsts and read instructions later… <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=126&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/12/03/ctp1-to-ctp2-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-smile.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/12/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>
	</item>
		<item>
		<title>Temporary file with given extension.</title>
		<link>http://becomelotr.wordpress.com/2011/11/29/temporary-file-with-given-extension/</link>
		<comments>http://becomelotr.wordpress.com/2011/11/29/temporary-file-with-given-extension/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 14:12:46 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/?p=122</guid>
		<description><![CDATA[Creating temporary file in PowerShell is pretty simple – because you can use .NET call directly it’s a matter of: [IO.Path]::GetTempFileName() The problem you may walk into is the rare case when your file has to have specific extension to &#8230; <a href="http://becomelotr.wordpress.com/2011/11/29/temporary-file-with-given-extension/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=122&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Creating temporary file in PowerShell is pretty simple – because you can use .NET call directly it’s a matter of:</p>
<pre class="PowerShellColorizedScript"><span style="color:#008080;">[IO.Path]</span><span style="color:#a9a9a9;">::</span><span style="color:#000000;">GetTempFileName</span><span style="color:#000000;">(</span><span style="color:#000000;">)</span>            </pre>
<p>The problem you may walk into is the rare case when your file has to have specific extension to work properly. I usually have this issue when I try to use temporary file to create formatting/ type information at runtime. If you leave .tmp extension, you can not use it for Update-*Data:</p>
<p><font color="#ff0000">Cannot read file &quot;C:\Users\bielawb\AppData\Local\Temp\tmp3069.tmp&quot;&#160; because it does not have the extension &quot;ps1xml&quot;.</font></p>
<p>Obviously – you need to rename the file. Nothing really tricky here. But with PowerShell’s pipeline model you can do all that in one go instead of juggling variables:</p>
<p><pre class="PowerShellColorizedScript"><span style="color:#008080;">[IO.Path]</span><span style="color:#a9a9a9;">::</span><span style="color:#000000;">GetTempFileName</span><span style="color:#000000;">(</span><span style="color:#000000;">)</span> <span style="color:#a9a9a9;">|</span>
    <span style="color:#0000ff;">Rename-Item</span> <span style="color:#000080;">-NewName</span> <span style="color:#000000;">{</span> <span style="color:#ff4500;">$_</span> <span style="color:#a9a9a9;">-replace</span> <span style="color:#8b0000;">'tmp$'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'ps1xml'</span> <span style="color:#000000;">}</span> –<span style="color:#000080;">PassThru</span></pre>
<p>You will get FileInfo object back, and it will have correct extension for *Data files. All you need to do is put your XML in it and change your environment to suite your needs. <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-winkingsmile1.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=122&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/11/29/temporary-file-with-given-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-winkingsmile1.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip: cleaning code copied from blogs.</title>
		<link>http://becomelotr.wordpress.com/2011/11/12/quick-tip-cleaning-code-copied-from-blogs/</link>
		<comments>http://becomelotr.wordpress.com/2011/11/12/quick-tip-cleaning-code-copied-from-blogs/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 11:28:59 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[quick tip]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/2011/11/12/quick-tip-cleaning-code-copied-from-blogs/</guid>
		<description><![CDATA[I’ve decided that from time to time I should use this blog to write down some tiny things I came up with while working/ playing with PowerShell. My memory is leaking all the time, and once I write something down &#8230; <a href="http://becomelotr.wordpress.com/2011/11/12/quick-tip-cleaning-code-copied-from-blogs/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=120&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve decided that from time to time I should use this blog to write down some tiny things I came up with while working/ playing with PowerShell. My memory is leaking all the time, and once I write something down – I will be able to come back to it when needed. <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-winkingsmile.png?w=584" /></p>
<p>Today I had need to copy some code from blog. Having PowerShell code on the blog is pretty neat, it’s usually nicer when you add line numbers. Line numbers are handy, but if you do not use plugin that allows others to take code without them – they get extra step of removing prefixes from copied “stuff”. Today I decided that it would be wiser to have some simple function to do that for me, instead of writing some one-liner each time:</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#8a2be2;">Remove-LinePrefix</span> <span style="color:#000000;">{</span>
<span style="color:#00008b;">param</span> <span style="color:#000000;">(</span>
    <span style="color:#a9a9a9;">[</span><span style="color:#00bfff;">Alias</span><span style="color:#000000;">(</span><span style="color:#8b0000;">'PrefixPattern'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'PP'</span><span style="color:#000000;">)</span><span style="color:#a9a9a9;">]</span>
    <span style="color:#008080;">[string]</span><span style="color:#ff4500;">$Pattern</span>
<span style="color:#000000;">)</span>            

<span style="color:#00008b;">if</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$Text</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$psISE</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CurrentFile</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Text</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
    <span style="color:#ff4500;">$Text</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$Text</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Split</span><span style="color:#000000;">(</span><span style="color:#8b0000;">&quot;`n&quot;</span><span style="color:#000000;">)</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">ForEach-Object</span> <span style="color:#000000;">{</span>
        <span style="color:#ff4500;">$_</span> <span style="color:#a9a9a9;">-replace</span> <span style="color:#ff4500;">$Pattern</span>
    <span style="color:#000000;">}</span>
    <span style="color:#ff4500;">$psISE</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">CurrentFile</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Editor</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Text</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$Text</span>
<span style="color:#000000;">}</span>
<span style="color:#000000;">}</span>             </pre>
<p>With this function defined I could copy code from blog directly to new ISE window and with single line (and proper regex pattern that would match only the prefix) clean it up:</p>
<pre class="PowerShellColorizedScript"><span style="color:#0000ff;">Remove-LinePrefix</span> <span style="color:#000080;">-Pattern</span> <span style="color:#8b0000;">'^\s+\d+:'</span></pre>
<p>Done! <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-smile.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=120&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/11/12/quick-tip-cleaning-code-copied-from-blogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/11/wlemoticon-smile.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>
	</item>
		<item>
		<title>Begin, process, end&#8230;</title>
		<link>http://becomelotr.wordpress.com/2011/10/25/begin-process-end/</link>
		<comments>http://becomelotr.wordpress.com/2011/10/25/begin-process-end/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 19:20:38 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[trace-command]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/2011/10/25/begin-process-end/</guid>
		<description><![CDATA[Few weeks ago I’ve discovered very strange bug in the way ‘process’ works when used in wrong context. Long story short: someone wrote function with process block, but without begin block. It’s usually OK, but he tried to put some &#8230; <a href="http://becomelotr.wordpress.com/2011/10/25/begin-process-end/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=117&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Few weeks ago I’ve discovered very strange bug in the way ‘process’ works when used in wrong context. Long story short: someone wrote function with process block, but without begin block. It’s usually OK, but he tried to put some code between param and process block and that gave him error, that is misleading at best:</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#8a2be2;">Test-BadProcess</span> <span style="color:#000000;">{</span>
<span style="color:#00008b;">param</span> <span style="color:#000000;">(</span><span style="color:#000000;">)</span>            

<span style="color:#006400;"># begin {</span>
<span style="color:#ff4500;">$SomeVariable</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'Initial Value'</span>
<span style="color:#006400;"># }</span>            

<span style="color:#0000ff;">process</span> <span style="color:#000000;">{</span>
    <span style="color:#8b0000;">&quot;Will barf on you! Get-Process does not take scripts! ARGH!&quot;</span>
<span style="color:#000000;">}</span>
<span style="color:#000000;">}</span></pre>
<p>So how it looks like when you run it?</p>
<p><a href="http://becomelotr.files.wordpress.com/2011/10/badprocess.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="BadProcess" border="0" alt="BadProcess" src="http://becomelotr.files.wordpress.com/2011/10/badprocess_thumb.png?w=644&#038;h=189" width="644" height="189" /></a></p>
<p>Oops? Get-Process? When did I used <strong>that</strong> command? It appears that when you use process in other context than it was designed to, it will automagically add ‘Get-‘ verb and surprise you. What is even more surprising – it will do the same with begin and end. But first it has to have something to run so…:</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">function</span> <span style="color:#0000ff;">Get-Begin</span> <span style="color:#000000;">{</span>
    <span style="color:#8b0000;">&quot;And now for something completely different!&quot;</span>
<span style="color:#000000;">}</span>            

<span style="color:#00008b;">function</span> <span style="color:#0000ff;">Get-End</span> <span style="color:#000000;">{</span>
    <span style="color:#8b0000;">&quot;This is the end... My only friend, the end...&quot;</span>
<span style="color:#000000;">}</span>            

<span style="color:#ff4500;">$null</span><span style="color:#000000;">;</span><span style="color:#0000ff;">begin</span>
<span style="color:#ff4500;">$null</span><span style="color:#000000;">;</span><span style="color:#0000ff;">end</span></pre>
<p>But that’s not all, folks. Unless you use something that PowerShell would not like (e.g. keywords that do not change into commands when context changes) or known already as a command (alias, application) you can just type Noun, and Get- will be added for you. How I’ve found out? Trace-Command told me… <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile2.png?w=584" /></p>
<p><a href="http://becomelotr.files.wordpress.com/2011/10/get-foo.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Get-Foo" border="0" alt="Get-Foo" src="http://becomelotr.files.wordpress.com/2011/10/get-foo_thumb.png?w=644&#038;h=152" width="644" height="152" /></a></p>
<p>The only question that remains open: why process/ begin/ end used in such context follow this rule? And few other keywords too (more on that later).</p>
<p><strong>BTW</strong>: in case you want to fix it yourself: my suggestion is to define three functions in your profile:</p>
<pre class="PowerShellColorizedScript"><span style="color:#00008b;">foreach</span> <span style="color:#000000;">(</span><span style="color:#ff4500;">$key</span> <span style="color:#00008b;">in</span> <span style="color:#8b0000;">'begin process end'</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Split</span><span style="color:#000000;">(</span><span style="color:#000000;">)</span><span style="color:#000000;">)</span> <span style="color:#000000;">{</span>
    <span style="color:#ff4500;">$Function</span> <span style="color:#a9a9a9;">=</span> <span style="color:#000000;">@{</span>
        <span style="color:#000000;">Path</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">&quot;function:\$key&quot;</span>
        <span style="color:#000000;">Value</span> <span style="color:#a9a9a9;">=</span> <span style="color:#008080;">[scriptblock]</span><span style="color:#a9a9a9;">::</span><span style="color:#000000;">Create</span><span style="color:#000000;">(</span>
            <span style="color:#8b0000;">&quot;throw 'Keyword ''$key'' used in wrong context!'&quot;</span>
        <span style="color:#000000;">)</span>
        <span style="color:#000000;">Force</span> <span style="color:#a9a9a9;">=</span> <span style="color:#ff4500;">$true</span>
    <span style="color:#000000;">}</span>
    <span style="color:#0000ff;">New-Item</span> <span style="color:#ff4500;">@Function</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">Out-Null</span>
<span style="color:#000000;">}</span>            </pre>
<p>Any of them should give you errors that are more accurate than what you get by default&#8230; You may want to fix also other surprising keywords that change into commands in context, where you might not expect it:</p>
<pre class="PowerShellColorizedScript"><span style="color:#8b0000;">'Begin'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Break'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Catch'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Continue'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Data'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Do'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Dynamicparam'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Else'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Elseif'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'End'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Exit'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Filter'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Finally'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'For'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Foreach'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'From'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Function'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'If'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'In'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Param'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Process'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Return'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Switch'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Throw'</span><span style="color:#a9a9a9;">,</span>
<span style="color:#8b0000;">'Trap'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Try'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Until'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'While'</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">ForEach-Object</span> <span style="color:#000000;">{</span>
    <span style="color:#8b0000;">&quot;$_&quot;</span><span style="color:#000000;">;</span><span style="color:#8b0000;">&quot;`$null;$_&quot;</span><span style="color:#000000;">;</span><span style="color:#8b0000;">&quot;} $_&quot;</span>
<span style="color:#000000;">}</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">ForEach-Object</span> <span style="color:#000000;">{</span>
    <span style="color:#008080;">[Management.Automation.PSParser]</span><span style="color:#a9a9a9;">::</span><span style="color:#000000;">Tokenize</span><span style="color:#000000;">(</span><span style="color:#ff4500;">$_</span><span style="color:#a9a9a9;">,</span> <span style="color:#008080;">[ref]</span><span style="color:#ff4500;">$null</span><span style="color:#000000;">)</span> <span style="color:#a9a9a9;">|</span>
    <span style="color:#0000ff;">Add-Member</span> <span style="color:#000080;">-MemberType</span> <span style="color:#8a2be2;">NoteProperty</span> <span style="color:#000080;">-Name</span> <span style="color:#8a2be2;">Line</span> <span style="color:#000080;">-Value</span> <span style="color:#ff4500;">$_</span> <span style="color:#000080;">-PassThru</span>
<span style="color:#000000;">}</span> <span style="color:#a9a9a9;">|</span> <span style="color:#0000ff;">Where-Object</span> <span style="color:#000000;">{</span> <span style="color:#ff4500;">$_</span><span style="color:#a9a9a9;">.</span><span style="color:#000000;">Type</span> <span style="color:#a9a9a9;">-in</span> <span style="color:#8b0000;">'Command'</span><span style="color:#a9a9a9;">,</span> <span style="color:#8b0000;">'Keyword'</span><span style="color:#000000;">}</span> <span style="color:#a9a9a9;">|</span>
    <span style="color:#0000ff;">Format-Table</span> <span style="color:#8a2be2;">Line</span><span style="color:#a9a9a9;">,</span> <span style="color:#8a2be2;">Type</span> <span style="color:#000080;">-AutoSize</span> <span style="color:#000080;">-GroupBy</span> <span style="color:#8a2be2;">Content</span></pre>
<p>Here you can see all keywords and how they switch their keyword-ness on and off.</p>
<p>I’m only sad I forgot to mention this to PowerShell Team during Deep Dive and ask why is that so. <img style="border-style:none;" class="wlEmoticon wlEmoticon-sadsmile" alt="Smutek" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-sadsmile.png?w=584" /> Note to self: next time prepare a list of questions <strong>before</strong> you go to conference like this one, amount of PowerShell goodness my overwhelm you and in the end – you forget what was that you wanted to ask. <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile2.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=117&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/10/25/begin-process-end/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/badprocess_thumb.png" medium="image">
			<media:title type="html">BadProcess</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile2.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/get-foo_thumb.png" medium="image">
			<media:title type="html">Get-Foo</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-sadsmile.png" medium="image">
			<media:title type="html">Smutek</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile2.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>
	</item>
		<item>
		<title>Kill cmd.exe</title>
		<link>http://becomelotr.wordpress.com/2011/10/23/kill-cmd-exe/</link>
		<comments>http://becomelotr.wordpress.com/2011/10/23/kill-cmd-exe/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 10:28:43 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmd]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/2011/10/23/kill-cmd-exe/</guid>
		<description><![CDATA[Where we are? How many time have I heard this question from other PowerShell enthusiasts: “when cmd.exe is going to die”. Or at best “when will PowerShell.exe become default when user asks for command line”. It’s not so in Windows &#8230; <a href="http://becomelotr.wordpress.com/2011/10/23/kill-cmd-exe/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=106&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Where we are?</h1>
<p>How many time have I heard this question from other PowerShell enthusiasts: “when cmd.exe is going to die”. Or at best “when will PowerShell.exe become default when user asks for command line”. It’s not so in Windows 8 Developer Preview, not sure what to expect in final release, but kind of don’t expect it to happen anytime soon. What is most frustrating for some is the fact, that server core still expects us to type “powershell.exe” once we boot.</p>
<h1>Where we would like to be?</h1>
<p>I’ve used cmd.exe for years. Never jumped on the vbscript wagon so I tried to squeeze every last drop from cmd.exe (must admit – I missed opportunity with wmic.exe, and came back to it when I was already using PowerShell for some time on legacy boxes where PowerShell was not an option). But for me – now when most of clients and servers in my organization have PowerShell on by default – I would like to hide it, just in case, and have PowerShell as my primary command line experience.</p>
<h1>How to get there?</h1>
<p>I’ve seen some tweaks to add PowerShell here and there. My answer is more general. Once you use this trick – you will have cmd.exe replaced <strong>everywhere</strong>. Any instance of cmd.exe will just pass you straight to PowerShell.exe. If you run it from other tool, if you run it from Explorer.exe ‘File’ menu in Windows 8, if you go to start &gt; Search program and files in Windows 7 and type ‘cmd.exe’ there…</p>
<p>All you have to do is add one registry key either to:</p>
<p align="center"><em>HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor</em></p>
<p align="center"><em>and/or</em></p>
<p align="center"><em>HKEY_CURRENT_USER\Software\Microsoft\Command Processor</em></p>
<p>The name of the property is ‘AutoRun’, it’s either Expandable String or just String. Tested on Windows 7, Windows 8 Server Developer Preview, Windows 2008 R2 (full server, no core virtuals on my box at the moment). In first try you can put simple “powershell.exe” there, and most of people should not need anything else. I’ve decided to resign from my usual profile (it’s quite heavy), change the title, and because I added command – I need to tell PowerShell to stay once it’s done:</p>
<p><a href="http://becomelotr.files.wordpress.com/2011/10/autorun-cmd-exe_.png" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="AutoRun-cmd.exe" border="0" alt="AutoRun-cmd.exe" src="http://becomelotr.files.wordpress.com/2011/10/autorun-cmd-exe_thumb.png?w=644&#038;h=31" width="644" height="31" /></a></p>
<p>And final result…? Just typed ‘cmd’ in explorer window on my Windows 7 box. And look what I got? PowerShell AT LAST! <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png?w=584" /></p>
<p><a href="http://becomelotr.files.wordpress.com/2011/10/cmdfromexplorer.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="cmdFromExplorer" border="0" alt="cmdFromExplorer" src="http://becomelotr.files.wordpress.com/2011/10/cmdfromexplorer_thumb.png?w=644&#038;h=214" width="644" height="214" /></a></p>
<p>And there is no much to code here:</p>
<pre class="PowerShellColorizedScript"><span style="color:#ff4500;">$ReplaceCmd</span> <span style="color:#a9a9a9;">=</span> <span style="color:#000000;">@{</span>
    <span style="color:#000000;">Path</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'HKLM:\SOFTWARE\Microsoft\Command Processor'</span>
    <span style="color:#000000;">Name</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'AutoRun'</span>
    <span style="color:#000000;">Value</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'powershell.exe -noexit -noprofile $host.UI.RawUI.WindowTitle = ''PowerShell AT LAST'''</span>
<span style="color:#000000;">}</span>            

<span style="color:#0000ff;">New-ItemProperty</span> <span style="color:#ff4500;">@ReplaceCmd</span> <span style="color:#000080;">-Force</span></pre>
<h1>How to get back?</h1>
<p>The answer is simple: one time – just type exit in PowerShell and you are back with your old friend. Don’t like this trick and what to have cmd.exe back for good? Just delete registry key and forget about it. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png?w=584" /> And because it’s registry you can have it on each and every machine you touch. Handy especially if you know that nobody else would ever want to use command line on particular box.</p>
<h1>How much will it cost?</h1>
<p>Well… there are at least two things you need to consider before you enable this tweak: do you use .cmd files and do you use cmd /c in your PowerShell scripts. This solution can in effect prevent you from both, so be careful… For /c solution is pretty straight forward: all you have to do is to use /d together with it (cmd /d /c dir e.g.). For .cmd files run by double-clicking is just a matter of registry fixes in HKLM:\Software\Classes\cmdfile\shell. Still a lot <strong>other </strong>things can go wrong… So remember if it does – check if removing this tweak won’t solve you problem. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=106&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/10/23/kill-cmd-exe/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/autorun-cmd-exe_thumb.png" medium="image">
			<media:title type="html">AutoRun-cmd.exe</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/cmdfromexplorer_thumb.png" medium="image">
			<media:title type="html">cmdFromExplorer</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile1.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell CTP &#8211; Care To Play? :)</title>
		<link>http://becomelotr.wordpress.com/2011/10/15/powershell-ctp-care-to-play/</link>
		<comments>http://becomelotr.wordpress.com/2011/10/15/powershell-ctp-care-to-play/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 10:41:16 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[CTP1]]></category>
		<category><![CDATA[V3]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/2011/10/15/powershell-ctp-care-to-play/</guid>
		<description><![CDATA[PowerShell CTPs are great. When I started to use PowerShell on a daily basis it was already v2 CTP2. And that is the main reason why I know very little about v1 It was just so much better experience… Same &#8230; <a href="http://becomelotr.wordpress.com/2011/10/15/powershell-ctp-care-to-play/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=99&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>PowerShell CTPs are great. When I started to use PowerShell on a daily basis it was already v2 CTP2. And that is the main reason why I know very little about v1 <img style="border-style:none;" class="wlEmoticon wlEmoticon-winkingsmile" alt="Puszczam oczko" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile.png?w=584" /> It was just so much better experience… Same happens now with <a href="http://www.microsoft.com/download/en/details.aspx?id=27548">v3 CTP1</a>. Once <a href="http://blogs.msdn.com/b/powershell/archive/2011/09/20/windows-management-framework-3-0-community-technology-preview-ctp-1-available-for-download.aspx">I saw it’s coming</a> – I started to look for a way to get all requirements on my primary machine. I haven’t really played with stuff that is new in version 3 – like workflows. What I concentrate on is stuff that got improved from version 2. And from my perspective there are few I simply could not ignore.</p>
<h1>ISE</h1>
<p>I’m using ISE all the time. It’s my console window, my script editor – you name it. I have tried several products – both commercial and free – but I always come back to ISE. And ISE in version 3 is much, much better. What I like the most is Intellisense and feature I asked for on this blog – support for XML (and ps1xml of course) syntax. It’s not perfect (yet?), but it’s step in the right direction. I also love new snippets feature. I love the fact, that errors are shown during editing file, which simplifies debugging. Code folding that is just brilliant way to find part of the script/ module quickly. And more… </p>
<h1>Building objects</h1>
<p>I mentioned it several times, and I will mention it once more: I’m big fan of hashtables, and whenever I can I try to use them. In v3 we will get very powerful syntax to create objects, both custom and real .NET types:</p>
<pre class="PowerShellColorizedScript"><span style="color:#008080;">[PSCustomObject]</span><span style="color:#000000;">@{</span>
    <span style="color:#000000;">Name</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'My Object'</span>
    <span style="color:#000000;">Version</span> <span style="color:#a9a9a9;">=</span> <span style="color:#008080;">[version]</span><span style="color:#8b0000;">'1.2.3.4'</span>
    <span style="color:#000000;">CreatedOn</span> <span style="color:#a9a9a9;">=</span> <span style="color:#0000ff;">Get-Date</span>
    <span style="color:#000000;">iLove</span> <span style="color:#a9a9a9;">=</span> <span style="color:#8b0000;">'PowerShell'</span>
    <span style="color:#000000;">CreatedBy</span> <span style="color:#a9a9a9;">=</span> <span style="color:#0000ff;">whoami</span>
<span style="color:#000000;">}</span></pre>
<p>It has big advantage over New-Object –Property – order of members is preserved, so my main issue with custom objects is gone. You can also keep order in normal hashtables, all you need to do is add [ordered] in front of hashtable construct. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile.png?w=584" /></p>
<h1>Commands when you need them</h1>
<p>I used to load several modules in my profile. That is no longer the&#160; case – most of commands I use are unique across modules and with the way CommandNotFound exception works (plus the way [TAB] behaves) I don’t have to memorize where I kept any of commands. They just work. Really, I was amazed how fluent it can be. There are of course some modules that have to be loaded in order to make any sense (like SparkPlug or ISEFun that extend ISE functionality) but if module is pure toolbox, with some commands I use from time to time – I just use them and PowerShell does the magic for me in the background.</p>
<h1>… and more</h1>
<p>I mean really – I’ve just scratched the surface. There are <a href="http://www.jonathanmedd.net/category/v3preview">whole blog series about new stuff in v3 CTP1</a>. I’ve just mentioned few I value most. Stuff like workflows, PowerShell Web Access and other new features are just mind blowing. Future looks very promising. <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile.png?w=584" /> And I can’t wait when I will have chance to speak about it with other PowerShell enthusiasts during <a href="http://www.theexpertsconference.com/europe/2011/general-information/2011-powershell-deep-dive/">PowerShell Deep Dive</a> next week. Woo – hoo! <img style="border-style:none;" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Szeroki uśmiech" src="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-openmouthedsmile.png?w=584" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=99&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/10/15/powershell-ctp-care-to-play/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-winkingsmile.png" medium="image">
			<media:title type="html">Puszczam oczko</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-smile.png" medium="image">
			<media:title type="html">Uśmiech</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/wlemoticon-openmouthedsmile.png" medium="image">
			<media:title type="html">Szeroki uśmiech</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell MVP!</title>
		<link>http://becomelotr.wordpress.com/2011/10/01/powershell-mvp/</link>
		<comments>http://becomelotr.wordpress.com/2011/10/01/powershell-mvp/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 21:26:04 +0000</pubDate>
		<dc:creator>Bartek Bielawski</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[MVP]]></category>

		<guid isPermaLink="false">https://becomelotr.wordpress.com/2011/10/01/powershell-mvp/</guid>
		<description><![CDATA[&#160; It’s been a while since I wrote something on this blog. I tried to focus more on my Polish blog, because I assumed there is enough blogs in English about PowerShell. But because I would like to share this &#8230; <a href="http://becomelotr.wordpress.com/2011/10/01/powershell-mvp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=84&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>It’s been a while since I wrote something on this blog. I tried to focus more on my <a href="http://powershellpl.wordpress.com/">Polish blog</a>, because I assumed there is enough blogs in English about PowerShell. But because I would like to share this news with everybody – here it is. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Today I’ve received e-mail fro <a href="mailto:support@mvpaward.com">support@mvpaward.com</a> – I was expecting it for a while. I knew that I was nominated (thanks again, Aleksandar!), I knew it was today when decision will be announced. But decision itself was surprising for me. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://becomelotr.files.wordpress.com/2011/10/mvp_fullcolor_forscreen.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="MVP_FullColor_ForScreen" border="0" alt="MVP_FullColor_ForScreen" src="http://becomelotr.files.wordpress.com/2011/10/mvp_fullcolor_forscreen_thumb.png?w=153&#038;h=240" width="153" height="240" /></a>&#160; </p>
<p>Bartek Bielawski, PowerShell MVP. It sound like a fairy tale to me. But it’s true. Thanks to all who helped me get that far! PowerShell Deep Dive is at my doors and I will go there as newest PowerShell MVP. That’s pure awesomeness. I’m having difficulty with touching the ground at the moment. WOW.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/becomelotr.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/becomelotr.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/becomelotr.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=becomelotr.wordpress.com&amp;blog=16116774&amp;post=84&amp;subd=becomelotr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://becomelotr.wordpress.com/2011/10/01/powershell-mvp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a4e859a1bab545691dc05b3fae64558?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bartekbielawski</media:title>
		</media:content>

		<media:content url="http://becomelotr.files.wordpress.com/2011/10/mvp_fullcolor_forscreen_thumb.png" medium="image">
			<media:title type="html">MVP_FullColor_ForScreen</media:title>
		</media:content>
	</item>
	</channel>
</rss>
