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

<channel>
	<title>PowerShell.cz</title>
	<atom:link href="http://powershell.cz/feed/" rel="self" type="application/rss+xml" />
	<link>http://powershell.cz</link>
	<description>Get-World &#124; ConvertTo-PowerShell</description>
	<lastBuildDate>Mon, 07 May 2012 15:09:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>My presentations</title>
		<link>http://powershell.cz/2012/05/07/my-presentations/</link>
		<comments>http://powershell.cz/2012/05/07/my-presentations/#comments</comments>
		<pubDate>Mon, 07 May 2012 15:09:01 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[MVA]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[TechDays]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=300</guid>
		<description><![CDATA[I was asked by my friend to point him to presentations I delivered this year. As it should be useful also for others I decided to summarize it to this post. Please note that all my presentations were in Czech so maybe not so useful for English speaking people. But at least you can can <a href="http://powershell.cz/2012/05/07/my-presentations/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I was asked by my friend to point him to presentations I delivered this year. As it should be useful also for others I decided to summarize it to this post. Please note that all my presentations were in Czech so maybe not so useful for English speaking people. But at least you can can my demo files as I added it to all sessions.</p>
<p><strong>PowerShell Virtual Academy</strong></p>
<p>Whole show was started in December when I agreed with my local IT Pro Evangelist that we&#8217;ll create four sessions over Live meeting. This was planned as beginning for people interested in PowerShell.</p>
<ol>
<li><a title="Uvod" href="http://blogs.technet.com/b/technetczsk/archive/2012/02/16/zaznam-prezentace-seznam-prikazu-a-qa-z-prvniho-dilu-powershell-akademie.aspx">Introduction to PowerShell</a></li>
<li><a title="pipeline" href="http://blogs.technet.com/b/technetczsk/archive/2012/02/23/zaznam-prezentace-seznam-prikazu-a-qa-z-druheho-dilu-powershell-akademie.aspx">Pipeline</a></li>
<li><a title="Export and PSDrive" href="http://blogs.technet.com/b/technetczsk/archive/2012/02/29/zaznam-prezentace-seznam-prikazu-a-qa-z-tretiho-dilu-powershell-akademie.aspx">Exports and PSDrives</a></li>
<li><a title="WMI and scripts" href="http://blogs.technet.com/b/technetczsk/archive/2012/03/08/zaznam-prezentace-seznam-prikazu-skripty-a-qa-ze-ctvrteho-dilu-powershell-akademie.aspx">WMI and scripts</a></li>
</ol>
<p>Every part contains link to video, presentation, scripts I used and whole transcription of the session. If there were some questions during session, it&#8217;s answered also in the article. <a href="http://blogs.technet.com/b/technetczsk/archive/2012/02/09/powershell-akademie-zacina-jiz-dnes.aspx">General overview</a> of the academy is accessible on TechNet.</p>
<p><strong>TechDays 2012</strong></p>
<p>&nbsp;</p>
<p>It was a great pleasure when I was asked to give a session about PowerShell v3 during Microsoft&#8217;s Czech biggest conference &#8211; TechDays. The conference was held in two cities &#8211; Brno and Praha. I really enjoyed both shows. There was a lot of questions after my sessions and in Prague I spent more than hour with answering. At the moment there is available <a href="http://www.microsoft.com/cze/microsoftdays/stazeni.aspx">only presentation</a> from this conference.</p>
<p><strong>Microsoft Virtual Academy</strong></p>
<p>Maybe you already heard about <a title="MVA" href="http://www.microsoftvirtualacademy.com/Home.aspx">Microsoft Virtual Academy</a> (MVA). It contains free lessons for different Microsoft related topics. I definitely recommend you to try some lesson related to your work. Anyway &#8211; we decided that we&#8217;ll move PowerShell Academy to MVA to allow people to use MVA environment for knowledge testing. Every MVA lesson contains also test at the end. So you can immediately check if you listened with open eyes and ears. You can find it at MVA web under <a href="https://www.microsoftvirtualacademy.com/tracks/powershell-akademie">PowerShell akademie</a>.</p>
<p><strong>Future</strong></p>
<p>I was already asked to continue with PowerShell Virtual Academy, so at the moment I am building an outline for additional (probably again four) lessons.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/05/07/my-presentations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Measure presentation length</title>
		<link>http://powershell.cz/2012/03/12/measure-presentation-length/</link>
		<comments>http://powershell.cz/2012/03/12/measure-presentation-length/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 15:00:35 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[TechDays]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=278</guid>
		<description><![CDATA[Last weeks I spent most of my time preparing the presentation for TechDays 2012. Not surprisingly &#8211; I was talking about PowerShell v3 in new Windows 8. As there was strict requirement for presentation length (60 minutes) I had to plan carefully. Therefore I decided to create small script to measure my presentation length. It reports <a href="http://powershell.cz/2012/03/12/measure-presentation-length/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Last weeks I spent most of my time preparing the presentation for <a title="Tech Days 2012" href="Measure presentation length">TechDays 2012</a>. Not surprisingly &#8211; I was talking about PowerShell v3 in new Windows 8. As there was strict requirement for presentation length (60 minutes) I had to plan carefully. Therefore I decided to create small script to measure my presentation length. It reports time for every topic I discussed.</p>
<p>Function uses simple comparison of two time stamps with <strong>New-TimeStamp</strong> cmdlet. Then it just shows it in console but also writes it to text file for future reference. Everything is hardcoded in function now. Maybe will change it in future, now it&#8217;s here just for future reference.</p>
<pre class="brush: powershell; title: ; notranslate">
function Show-PresentationLength
{
    BEGIN
    {
        $Global:Presentation=@{}
        $path = &quot;$env:USERPROFILE&quot; + '\Documents\PresentationTiming.txt'
        Out-File -FilePath $path -InputObject (Get-Date) -Append
    }

    PROCESS
    {
        Read-Host &quot;Start ($_)&quot;
        $start = Get-Date
        Write-Host &quot;Running $_ ...&quot; -Fore Yellow -NoNewline
        Read-Host &quot;Stop ($_)&quot;
        $end = Get-Date

        $cycle = New-TimeSpan -Start $start -End $end

        $Global:Presentation[[int]$_]=$cycle
        $Presentation.GetEnumerator() |% -Begin {$sum=0} -Process {$sum+=$_.Value}

        &quot;Time ($_): {0:mm}:{0:ss}&quot; -f $cycle
        Out-File -FilePath $path -InputObject &quot;Time ($_): $cycle of ($sum)&quot; -Append
    }

    END
    {
        Clear-Host
        &quot;Total Time: {0:hh}:{0:mm}:{0:ss}&quot; -f $sum
        Out-File -FilePath $path -InputObject &quot;Total Time: $sum&quot; -Append
        foreach ( $s in $($Global:Presentation.GetEnumerator() | Sort Name) )
        {
            &quot;Slide {0}: {1:mm}:{1:ss}&quot; -f $s.Name, $s.Value
        }
    }
}
</pre>
<p>When I wanted to test length of some topic I discussed, I just started it this way (checking time for first three slides):</p>
<p class="code">PS C:\&gt; 1..3|Show-PresentationLength<br />
Start (1):<br />
Running 1 &#8230;Stop (1):<br />
Time (1): 00:10<br />
Start (2):<br />
Running 2 &#8230;Stop (2):<br />
Time (2): 00:14<br />
Start (3):<br />
Running 3 &#8230;Stop (3):<br />
Time (3): 00:14<br />
Total Time: 00:00:39<br />
Slide 1: 00:10<br />
Slide 2: 00:14<br />
Slide 3: 00:14</p>
<p>And can also see result in mentioned file (it also contains history).</p>
<p><img class="alignnone" title="Results in text file" src="http://powershell.cz/images/measure-pres-time/PresentationTimingTXT.png" alt="" width="556" height="357" /></p>
<p>BTW: Also because of this script I was able to finish both my presentations on time <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/03/12/measure-presentation-length/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>See Enums for last failed command</title>
		<link>http://powershell.cz/2012/02/27/see-enums-for-last-failed-command/</link>
		<comments>http://powershell.cz/2012/02/27/see-enums-for-last-failed-command/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 18:06:30 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[hint]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=261</guid>
		<description><![CDATA[During last PowerShell Academy session I received a question if it&#8217;s possible to have own color as argument for ForegroundColor parameter of Write-Host cmdlet. My answer was &#8211; no, and I then showed how to see available values &#8211; either in console directly (by providing non-existed value) or to check MSDN help for System.ConsoleColor. I like the <a href="http://powershell.cz/2012/02/27/see-enums-for-last-failed-command/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>During last <a href="http://blogs.technet.com/b/technetczsk/archive/2012/01/09/zveme-vas-na-powershell-akademii.aspx">PowerShell Academy</a> session I received a question if it&#8217;s possible to have own color as argument for <strong>ForegroundColor</strong> parameter of <strong>Write-Host</strong> cmdlet. My answer was &#8211; <em>no</em>, and I then showed how to see available values &#8211; either in console directly (by providing non-existed value) or to check MSDN help for <a href="http://msdn.microsoft.com/en-us/library/system.consolecolor.aspx">System.ConsoleColor</a>.</p>
<p>I like the idea of console way &#8211; anytime you provide some non-existing value, PowerShell will show you correct values as part of exception raised. I was then thinking about something more &#8211; hmm &#8211; elegant (?). Usually I just copy name of used enumeration and paste it to <strong><a href="http://msdn.microsoft.com/en-us/library/system.enum.getvalues.aspx">GetValues()</a></strong> method of <a href="http://msdn.microsoft.com/en-us/library/1zt1ybx4.aspx">Enum class</a>.</p>
<pre>[206]: Write-Host 'text' -ForegroundColor SomeColor
<span style="color: #ff0000;">Write-Host : Cannot bind parameter 'ForegroundColor'. Cannot convert value "SomeColor" to type "System.ConsoleColor" du</span>
<span style="color: #ff0000;">e to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeratio</span>
<span style="color: #ff0000;">n values are "Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan</span>
<span style="color: #ff0000;">, Red, Magenta, Yellow, White".</span>
<span style="color: #ff0000;">At line:1 char:35</span>
<span style="color: #ff0000;">+ Write-Host 'text' -ForegroundColor &lt;&lt;&lt;&lt; SomeColor</span>
<span style="color: #ff0000;"> + CategoryInfo : InvalidArgument: (:) [Write-Host], ParameterBindingException</span>
<span style="color: #ff0000;"> + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WriteHostCommand</span>

[207]: [enum]::GetValues([System.ConsoleColor])
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White</pre>
<p>Then I came with following function.</p>
<pre><span style="color: #0000FF;">function</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">Get-EnumValue</span><span style="color: #000000;">
{
  [CmdletBinding()]
  </span><span style="color: #0000FF;">param</span><span style="color: #000000;">()
  
  </span><span style="color: #5F9EA0; font-weight: bold;">Write-Verbose</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Checking last error.</span><span style="color: #800000;">'</span><span style="color: #000000;">
  </span><span style="color: #800080;">$e</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$Global:Error</span><span style="color: #000000;">[0].Exception

  </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$e</span><span style="color: #000000;">.ParameterType.IsEnum)
  {  
    </span><span style="color: #5F9EA0; font-weight: bold;">Write-Verbose</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Is Enum.</span><span style="color: #800000;">'</span><span style="color: #000000;">
    </span><span style="color: #5F9EA0; font-weight: bold;">Write-Verbose</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Enum name: $($e.ParameterType)</span><span style="color: #800000;">"</span><span style="color: #000000;">
    
    [</span><span style="color: #008080;">enum</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">GetValues</span><span style="color: #000000;">(</span><span style="color: #800080;">$e</span><span style="color: #000000;">.ParameterType.FullName)
  }
  </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> 
  { 
    </span><span style="color: #5F9EA0; font-weight: bold;">Write-Verbose</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Not Enum!</span><span style="color: #800000;">'</span><span style="color: #000000;">
  }
}</span></pre>
<p>Run it every time you receive an error mentioning that you used bad value for enumeration. Function will check last error (stored in $Error[0]) and if it contains notice that it&#8217;s related to enum, function will return all enum values. I created alias <strong>genum</strong> for that and put it to my profile.</p>
<pre>[208]: Write-Host 'text' -ForegroundColor SomeColor
<span style="color: #ff0000;">Write-Host : Cannot bind parameter 'ForegroundColor'. Cannot convert value "SomeColor" to type "System.ConsoleColor" du</span>
<span style="color: #ff0000;">e to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeratio</span>
<span style="color: #ff0000;">n values are "Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan</span>
<span style="color: #ff0000;">, Red, Magenta, Yellow, White".</span>
<span style="color: #ff0000;">At line:1 char:35</span>
<span style="color: #ff0000;">+ Write-Host 'text' -ForegroundColor &lt;&lt;&lt;&lt; SomeColor</span>
<span style="color: #ff0000;"> + CategoryInfo : InvalidArgument: (:) [Write-Host], ParameterBindingException</span>
<span style="color: #ff0000;"> + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WriteHostCommand</span>

[209]: Get-EnumValue
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White
[210]: Get-Command -CommandType Something
<span style="color: #ff0000;">Get-Command : Cannot bind parameter 'CommandType'. Cannot convert value "Something" to type "System.Management.Automation.Com</span>
<span style="color: #ff0000;">mandTypes" due to invalid enumeration values. Specify one of the following enumeration values and try again. The possib</span>
<span style="color: #ff0000;">le enumeration values are "Alias, Function, Filter, Cmdlet, ExternalScript, Application, Script, All".</span>
<span style="color: #ff0000;">At line:1 char:25</span>
<span style="color: #ff0000;">+ Get-Command -CommandType &lt;&lt;&lt;&lt; sgd</span>
<span style="color: #ff0000;"> + CategoryInfo : InvalidArgument: (:) [Get-Command], ParameterBindingException</span>
<span style="color: #ff0000;"> + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetCommandCommand</span>

[211]: genum
Alias
Function
Filter
Cmdlet
ExternalScript
Application
Script
All
[212]: gc notExists
<span style="color: #ff0000;">Get-Content : Cannot find path 'Dropbox:\PowerShell\Scripts\notExists' because it does not exist.</span>
<span style="color: #ff0000;">At line:1 char:3</span>
<span style="color: #ff0000;">+ gc &lt;&lt;&lt;&lt; notExists</span>
<span style="color: #ff0000;"> + CategoryInfo : ObjectNotFound: (Dropbox:\PowerShell\Scripts\notExists:String) [Get-Content], ItemNotFou</span>
<span style="color: #ff0000;"> ndException</span>
<span style="color: #ff0000;"> + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand</span>

[213]: genum
[214]:</pre>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/02/27/see-enums-for-last-failed-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto complete for about_* topics</title>
		<link>http://powershell.cz/2012/01/07/auto-complete-for-about_-topics/</link>
		<comments>http://powershell.cz/2012/01/07/auto-complete-for-about_-topics/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 19:21:00 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=256</guid>
		<description><![CDATA[Today I was heavily working with PowerShell help system. And was tired to call it using Get-Help cmdlet. So I created small function which I put to my profile: function Show-HelpAboutFunction { $topics = Get-Help about_* foreach ($t in $topics) { $tn = $t.Name -replace 'about_', 'abt-' $text = "function global:$($tn) { Get-Help $($t.Name) }" <a href="http://powershell.cz/2012/01/07/auto-complete-for-about_-topics/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Today I was heavily working with PowerShell help system. And was tired to call it using Get-Help cmdlet. So I created small function which I put to my profile:</p>
<pre><span style="color: #0000FF;">function</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">Show-HelpAboutFunction</span><span style="color: #000000;">
{
    </span><span style="color: #800080;">$topics</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">Get-Help</span><span style="color: #000000;"> about_</span><span style="color: #800000;">*</span><span style="color: #000000;"> 

    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$t</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$topics</span><span style="color: #000000;">)
    {
        </span><span style="color: #800080;">$tn</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$t</span><span style="color: #000000;">.Name </span><span style="color: #FF0000;">-replace</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">about_</span><span style="color: #800000;">'</span><span style="color: #000000;">, </span><span style="color: #800000;">'</span><span style="color: #800000;">abt-</span><span style="color: #800000;">'</span><span style="color: #000000;">
        </span><span style="color: #800080;">$text</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">function global:$($tn) { Get-Help $($t.Name) }</span><span style="color: #800000;">"</span><span style="color: #000000;">

        </span><span style="color: #5F9EA0; font-weight: bold;">Invoke-Expression</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">$text</span><span style="color: #800000;">"</span><span style="color: #000000;">
    }
}</span></pre>
<p>So when in console I can write: <strong>abt-func&lt;Tab&gt;</strong> and can circulate help topics till have the one I need. I know that for some topics is better to write Get-Help with partial help topic name, but in some cases I like my solution more.</p>
<p>Note: I know that abt is not approved verb <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/01/07/auto-complete-for-about_-topics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISE: List variables in active Script Pane</title>
		<link>http://powershell.cz/2012/01/01/ise-list-variables-in-active-script-pane/</link>
		<comments>http://powershell.cz/2012/01/01/ise-list-variables-in-active-script-pane/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 17:21:11 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ISE]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=243</guid>
		<description><![CDATA[I was working in ISE pretty much during last two days (oh yes, was nice end of 2011 and beginning of 2012). During script creation I was checking values of variables frequently. Wouldn&#8217;t be nice to see variables value and not just write it&#8217;s name to Command Pane? So I came with another menu Add-on <a href="http://powershell.cz/2012/01/01/ise-list-variables-in-active-script-pane/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I was working in ISE pretty much during last two days (oh yes, was nice end of 2011 and beginning of 2012). During script creation I was checking values of variables frequently. Wouldn&#8217;t be nice to see variables value and not just write it&#8217;s name to Command Pane? So I came with another menu Add-on command.</p>
<pre><span style="color: #0000FF;">function</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">GetValues</span><span style="color: #000000;">
{
    </span><span style="color: #800080;">$content</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentFile.Editor.Text
    </span><span style="color: #800080;">$tokens</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> [</span><span style="color: #008080;">System.Management.Automation.PsParser</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">Tokenize</span><span style="color: #000000;">(</span><span style="color: #800080;">$content</span><span style="color: #000000;">, [</span><span style="color: #008080;">ref</span><span style="color: #000000;">] </span><span style="color: #800080;">$null</span><span style="color: #000000;">) |? {</span><span style="color: #800080;">$_</span><span style="color: #000000;">.Type </span><span style="color: #FF0000;">-eq</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Variable</span><span style="color: #800000;">'</span><span style="color: #000000;">} | </span><span style="color: #5F9EA0; font-weight: bold;">Sort</span><span style="color: #000000;"> </span><span style="color: #800000;">Content</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Unique</span><span style="color: #000000;">

    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$t</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$tokens</span><span style="color: #000000;">)
    {
        </span><span style="color: #800080;">$prop</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> @{
            Name </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$t</span><span style="color: #000000;">.Content
            Value </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">Get-Variable</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Name</span><span style="color: #000000;"> $(</span><span style="color: #800080;">$t</span><span style="color: #000000;">.Content) </span><span style="color: #5F9EA0; font-style: italic;">-ValueOnly</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ErrorAction</span><span style="color: #000000;"> </span><span style="color: #800000;">SilentlyContinue</span><span style="color: #000000;">
        }

        </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-TypeName</span><span style="color: #000000;"> </span><span style="color: #800000;">PSObject</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Property</span><span style="color: #000000;"> </span><span style="color: #800080;">$prop</span><span style="color: #000000;"> | </span><span style="color: #5F9EA0; font-weight: bold;">Select</span><span style="color: #000000;"> Name, </span><span style="color: #800000;">Value</span><span style="color: #000000;">
    }
}

</span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(</span><span style="color: #800000;">'</span><span style="color: #800000;">Show values</span><span style="color: #800000;">'</span><span style="color: #000000;">,{</span><span style="color: #5F9EA0;">GetValues</span><span style="color: #000000;">},</span><span style="color: #800000;">'</span><span style="color: #800000;">CTRL+SHIFT+V</span><span style="color: #800000;">'</span><span style="color: #000000;">) | </span><span style="color: #5F9EA0; font-weight: bold;">Out-Null</span></pre>
<p>When you work with any script, you can run it and will see all actual script variables in <em>Output Pane</em>.</p>
<p><img class="alignnone" title="Variables in current script" src="http://www.powershell.cz/images/ISE-get-values/ISE_GetValues.jpg" alt="Variables in current script" width="710" height="568" /></p>
<p>Using Tokenizer API I received all variables from current script and created new object with variable name and value. Then it&#8217;s send to output. I am thinking about some graphical output (WPF or ShowUI) or just to Out-GridView. There are also some another points to update but for my current needs it&#8217;s OK.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/01/01/ise-list-variables-in-active-script-pane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISE: Run current line without selecting, AKA v3 feature</title>
		<link>http://powershell.cz/2012/01/01/ise-run-current-line-without-selecting-aka-v3-feature/</link>
		<comments>http://powershell.cz/2012/01/01/ise-run-current-line-without-selecting-aka-v3-feature/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 13:19:42 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ISE]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=226</guid>
		<description><![CDATA[I like one of new PowerShell v3 features. When you are in ISE and want to run current line, just press F8, it&#8217;s no more necessary to select the line and then use Run Selection (F8). I&#8217;d like to have it in v2 also so I created another quick function: function RunLine { $editor = <a href="http://powershell.cz/2012/01/01/ise-run-current-line-without-selecting-aka-v3-feature/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I like one of new PowerShell v3 features. When you are in ISE and want to run current line, just press F8, it&#8217;s no more necessary to select the line and then use <em>Run Selection (F8)</em>. I&#8217;d like to have it in v2 also so I created another quick function:</p>
<pre><span style="color: #0000FF;">function</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">RunLine</span><span style="color: #000000;">
{
    </span><span style="color: #800080;">$editor</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentFile.Editor
    </span><span style="color: #800080;">$currentLine</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$editor</span><span style="color: #000000;">.CaretLine
    </span><span style="color: #800080;">$currentLineLength</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$editor</span><span style="color: #000000;">.GetLineLength(</span><span style="color: #800080;">$currentLine</span><span style="color: #000000;">)
    </span><span style="color: #800080;">$currentPosition</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$editor</span><span style="color: #000000;">.CaretColumn

    </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentFile.Editor.Select(
        </span><span style="color: #800080;">$currentLine</span><span style="color: #000000;">, </span><span style="color: #000000;">1</span><span style="color: #000000;">,
        </span><span style="color: #800080;">$currentLine</span><span style="color: #000000;">, </span><span style="color: #800080;">$currentLineLength</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">
    )

    </span><span style="color: #800000;">"</span><span style="color: #800000;">Running &gt;&gt; $($psISE.CurrentFile.Editor.SelectedText)</span><span style="color: #800000;">"</span><span style="color: #000000;">
    </span><span style="color: #5F9EA0; font-weight: bold;">Invoke-Expression</span><span style="color: #000000;"> </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentFile.Editor.SelectedText

    </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentFile.Editor.Select(
        </span><span style="color: #800080;">$currentLine</span><span style="color: #000000;">, </span><span style="color: #800080;">$currentPosition</span><span style="color: #000000;">,
        </span><span style="color: #800080;">$currentLine</span><span style="color: #000000;">, </span><span style="color: #800080;">$currentPosition</span><span style="color: #000000;">
    )
}

</span><span style="color: #800080;">$makovecRoot</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$psISE</span><span style="color: #000000;">.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(</span><span style="color: #800000;">"</span><span style="color: #800000;">Makovec</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800080;">$null</span><span style="color: #000000;">, </span><span style="color: #800080;">$null</span><span style="color: #000000;">)
</span><span style="color: #800080;">$makovecRoot</span><span style="color: #000000;">.Submenus.Add(</span><span style="color: #800000;">'</span><span style="color: #800000;">Run line</span><span style="color: #800000;">'</span><span style="color: #000000;">,{</span><span style="color: #5F9EA0;">RunLine</span><span style="color: #000000;">},</span><span style="color: #800000;">'</span><span style="color: #800000;">CTRL+F8</span><span style="color: #800000;">'</span><span style="color: #000000;">) | </span><span style="color: #5F9EA0; font-weight: bold;">Out-Null</span></pre>
<p>It allows me to be at some line and by pressing Ctrl+F8 just run it:</p>
<p><img class="alignnone" title="Run current line" src="http://www.powershell.cz/images/ISE-run-line/ISE_RunLine.jpg" alt="Run current line" width="678" height="495" /></p>
<p>If you want to see another cool new features in ISE v3, go to <a title="WMF 3.0 CTP2" href="http://www.microsoft.com/download/en/details.aspx?id=27548">Windows Management Framework 3.0 CTP2</a> page and download document named <a href="http://www.microsoft.com/downloads/info.aspx?na=41&amp;srcfamilyid=94895b51-8376-45ec-8fdd-4fd472e49aa3&amp;srcdisplaylang=en&amp;u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fA%2fF%2f1%2fAF1D6992-54EC-47CD-B2BF-38A68C171641%2fWindows%20PowerShell%20ISE.pdf">Windows PowerShell ISE.pdf</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2012/01/01/ise-run-current-line-without-selecting-aka-v3-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISE: Add new line below/above current</title>
		<link>http://powershell.cz/2011/12/28/ise-add-new-line-below-current/</link>
		<comments>http://powershell.cz/2011/12/28/ise-add-new-line-below-current/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 16:18:43 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ISE]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=217</guid>
		<description><![CDATA[Today I was playing with PowerShell v3 and was frequently working inside ISE (love it&#8217;s Intellisense feature). I was in this situation few times: As you can see, cursor is at position 0. At this time I want to add new line, so it means go to end of current line and press Enter. I <a href="http://powershell.cz/2011/12/28/ise-add-new-line-below-current/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Today I was playing with PowerShell v3 and was frequently working inside ISE (love it&#8217;s Intellisense feature). I was in this situation few times:</p>
<p><img class="alignnone" title="Cursor at position zero" src="http://www.powershell.cz/images/newline/cursorISE0position.jpg" alt="Cursor at position zero" width="627" height="53" /></p>
<p>As you can see, cursor is at position 0. At this time I want to add new line, so it means go to end of current line and press Enter. I wanted to automate it. Fortunately ISE object model is self-descriptive, so I created this small Add-on:</p>
<pre>$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Insert line below',
    {
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine,
        $psise.CurrentFile.Editor.GetLineLength($psise.CurrentFile.Editor.CaretLine)+1,
        $psise.CurrentFile.Editor.CaretLine,
        $psise.CurrentFile.Editor.GetLineLength($psise.CurrentFile.Editor.CaretLine)+1)
    $psise.CurrentFile.Editor.InsertText("`n")
    }, "CTRL+ENTER")

$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(
'Shift line',
    {
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine, 1,
        $psise.CurrentFile.Editor.CaretLine, 1)
    $psise.CurrentFile.Editor.InsertText("`n")
    $psise.CurrentFile.Editor.Select(
        $psise.CurrentFile.Editor.CaretLine-1, 1,
        $psise.CurrentFile.Editor.CaretLine-1, 1)
    }, "CTRL+SHIFT+ENTER")</pre>
<p>I added two features: add line below and before (shift line). You can call it either from menu:</p>
<p><img class="alignnone" title="Add-on menu" src="http://www.powershell.cz/images/newline/ISEinsertLine.jpg" alt="Add-on menu" width="399" height="99" /></p>
<p>or via keyboard shortcuts.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/12/28/ise-add-new-line-below-current/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>if ($PSVersionTable.PSVersion.Major -eq 3) { Start-Fun }</title>
		<link>http://powershell.cz/2011/09/15/whenpsv3/</link>
		<comments>http://powershell.cz/2011/09/15/whenpsv3/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 22:32:00 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[v3]]></category>
		<category><![CDATA[Win8]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=197</guid>
		<description><![CDATA[As you all already read during last day, Microsoft showed Windows 8 at it&#8217;s Build conference. There are big changes in OS and I am sure there will be tons of articles about it. But for PowerShell enthusiasts in means something else. PowerShell version 3 is a part of new OS Today, lot of people <a href="http://powershell.cz/2011/09/15/whenpsv3/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>As you all already read during last day, Microsoft showed Windows 8 at it&#8217;s Build conference. There are big changes in OS and I am sure there will be tons of articles about it. But for PowerShell enthusiasts in means something else. PowerShell version 3 is a part of new OS <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Today, lot of people mentioned the most obvious changes/news/thoughts. To name a few:</p>
<ul>
<li>Dmitry Sotnikov &#8211; <a href="http://dmitrysotnikov.wordpress.com/2011/09/14/first-glimpse-at-powershell-v3/">First Glimpse at PowerShell v3</a></li>
<li>Jonathan Medd: <a href="http://www.jonathanmedd.net/2011/09/powershell-v3-a-quick-first-look.html">PowerShell v3 &#8211; A Quick First Look</a> and <a href="http://www.jonathanmedd.net/2011/09/powershell-ise-v3-now-with-intellisense.html">PowerShell ISE v3 &#8211; Now With IntelliSense</a></li>
<li><a href="http://twitter.com/jaykul">@Jaykul</a> &#8211; had some great tweets about short (and clever as usual) hints</li>
</ul>
<p>After first check, I like following points:</p>
<ul>
<li>IntelliSense in ISE &#8211; it works in both -<a href="http://www.powershell.cz/images/whenpsv3/ISEisScriptPane.jpg"> Script Pane</a> and <a href="http://www.powershell.cz/images/whenpsv3/ISEisCommandPane.jpg">Command Pane</a>. Watch <a href="http://www.powershell.cz/images/whenpsv3/ISEisMethProp.jpg">different icons</a> for different types.</li>
<li><a href="http://www.powershell.cz/images/whenpsv3/ISECommands.jpg">Commands Add-on</a> in ISE - for me it looks like great tool for people new to PowerShell. They are able to see all possible parameters at one place and can easily fill/add it to current session. It contains question mark button which opens help for active cmdlet. When you fill all necessary parameters, you can insert result to your session. <em>Unfortunately</em> &#8211; it looks to me that it fully works only for cmdlets from core modules (Microsoft.PowerShell.*) and not for functions.</li>
<li><a href="http://www.powershell.cz/images/whenpsv3/ISEregions.jpg">Support for #region</a>, #endregion in ISE &#8211; collapsible.</li>
<li>ISE also support collapsing of expressions in brackets. As you can see on the <a href="http://www.powershell.cz/images/whenpsv3/ISEregions.jpg">picture</a> it&#8217;s also highlighting matching braces.</li>
<li>New way how modules loading work. You can use tab completion for functions even the module is not loaded. Again one point &#8211; what I tested till now it looks that it not work for script module (but need to test more with Export-ModuleMember).</li>
<li>There is a module CimCmdlets - have to check it as it should be useful for my work.</li>
</ul>
<p>Unfortunately I had to work today, so had not as many time as I wanted for some searching <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Fortunately &#8211; will have holiday for next three weeks, so there will be enough time for other posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/09/15/whenpsv3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ChmToMobi Module</title>
		<link>http://powershell.cz/2011/09/11/chmtomobi-module/</link>
		<comments>http://powershell.cz/2011/09/11/chmtomobi-module/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 14:54:24 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Kindle]]></category>
		<category><![CDATA[Module]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=184</guid>
		<description><![CDATA[It&#8217;s a year now since I bought Kindle for me. I have it still with me and frequently need to check PowerShell documentation. It led me to previous articles (1st and 2nd part) where I described in general, how to convert CHM file to MOBI. As I needed to automate it a bit, I created <a href="http://powershell.cz/2011/09/11/chmtomobi-module/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a year now since I bought <a title="Kindle" href="http://www.amazon.com/Kindle-Wireless-Reader-Wifi-Graphite/dp/B002Y27P3M">Kindle</a> for me. I have it still with me and frequently need to check PowerShell documentation. It led me to previous articles (<a href="http://powershell.cz/2011/01/05/powershell-help-on-kindle/">1st</a> and <a href="http://powershell.cz/2011/01/07/how-to-work-with-kindlegen/">2nd</a> part) where I described in general, how to convert CHM file to MOBI. As I needed to automate it a bit, I created simple module for conversion process. Whole process is simple:</p>
<ol>
<li><a href="http://www.powershell.cz/files/chm2mobi.zip">Download</a> ZIP file and unzip in to your module folder.</li>
<li>Import module to your session (<em>Import-Module chm2mobi</em>).</li>
<li>Run <em>Convert-ChmToMobi &lt;your_chm_file&gt;.</em></li>
<li>Copy MOBI to your e-reader and enjoy <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>To run it successfully, you need to have <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&amp;docId=1000234621">kindlegen</a> installed on your computer and need to set alias <em>kg</em> to point to EXE file. On my PC I did it this way:</p>
<pre>[11]: Get-Alias kg | ft -auto

CommandType Name Definition
----------- ---- ----------
Alias       kg   Dropbox:\Ruzne\KindleGen\kindlegen.exe</pre>
<p>This is example output when generating file for PowerShell help topics (I recommend to use -Verbose parameter so you&#8217;ll see actual state of processing):</p>
<pre>[16]: Convert-ChmToMobi .\PSHelp.chm

***********************************************
* Amazon.com kindlegen(Windows) V1.1 build 99 *
* A command line e-book compiler              *
* Copyright Amazon.com 2010                   *
***********************************************

opt version: try to minimize (default)
Info(prcgen): Added metadata dc:Title        "Title"
Info(prcgen): Added metadata dc:Date         "2011/09/11"
Info(prcgen): Added metadata dc:Creator      "moravec"
Info(prcgen): Added metadata dc:Subject      "Subject"
Info(prcgen): Added metadata dc:Description  "Description"
Info(prcgen): Parsing files  0000374
Warning(prcgen): &lt;INPUT&gt;, &lt;SELECT&gt; or &lt;TEXTAREA&gt; tag does no

Info(prcgen): Resolving hyperlinks
Info(prcgen): Resolving start reading location
Info(prcgen): Added metadata Start reading   "5098"
Info(prcgen): Computing UNICODE ranges used in the book
Info(prcgen): Found UNICODE range: Basic Latin [20..7E]
Info(prcgen): Found UNICODE range: General Punctuation - Windows 1252 [201C..201E]
Info(prcgen): Found UNICODE range: Latin-1 Supplement [A0..FF]
Info(prcgen): Building MOBI file, record count:   0001986
Info(prcgen): Compiling HTML Parser restart information
Info(prcgen): Final stats - text compressed to (in % of original size):  040.46%
Info(prcgen): The document identifier is: "Title"
Info(prcgen): The file format version is V6
Info(prcgen): Saving MOBI file
Info(prcgen): MOBI File successfully generated!</pre>
<p>There are still some points I need to update or change. For example:</p>
<ul>
<li>Easily add own Subject and Description.</li>
<li>Resolve problems when kindlegen alias not presented.</li>
<li>Add more control over generating files &#8211; generate only some files.</li>
<li>Not show kindlegen output when not requested.</li>
<li>Remove files at the end when requested.</li>
</ul>
<div>You can check <em>Get-Help Convert-ChmToMobi</em> if you need more info. <strong>Note:</strong> Time of file processing it really dependent on your HW. On my PC it tool almost 90 minutes to generate MOBI for Lync server, but on Tom&#8217;s (see below) it was about three minutes.</div>
<div>I&#8217;d like to send big thanks Tom Arbuthnot (<a title="Tom's Twitter" href="http://twitter.com/tomarbuthnot">@tomarbuthnot</a>) for initial testing of this module.</div>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/09/11/chmtomobi-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick file processing</title>
		<link>http://powershell.cz/2011/08/14/quick-file-processing/</link>
		<comments>http://powershell.cz/2011/08/14/quick-file-processing/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 08:09:28 +0000</pubDate>
		<dc:creator>makovec</dc:creator>
				<category><![CDATA[ConfigMgr]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[MMS]]></category>

		<guid isPermaLink="false">http://powershell.cz/?p=161</guid>
		<description><![CDATA[How to pack&#038;go content of MMS 2011 DVDs.]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://twitter.com/#!/makovec/status/100556298059395072">received</a> DVDs from <a href="http://www.mms-2011.com/">MMS</a> on Monday. What a nice day <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  As I wasn&#8217;t in Vegas, these DVDs are opportunity to see all those interesting presentations at home. My wife was out of town this weekend so I had a plan &#8211; MMS party <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Wanted to watch everything I marked as interesting. My idea was to create one DVD with presentations I selected and play it on TV (and preferably do not leave my bed).</p>
<p>I moved selected folders to one place, you can see structure of BA02 session folder here (it&#8217;s the same for all sessions):</p>
<p><img class="alignnone" title="Show session folder content" src="http://powershell.cz/images/quick-file-processing/MMS_ShowTree.jpg" alt="" width="420" height="220" /></p>
<p>In directory with session code is places file video.wmv. Eh &#8211; not so good to place every video to root of DVD. So I <span style="text-decoration: line-through;">opened explorer and copied every WMV file to specific location, changed it&#8217;s name to session code and did the same for all sessions I selected</span> used PowerShell to process all files. BTW: If you like <strong>Show-Tree</strong>, it&#8217;s part of <a title="PSCX" href="http://pscx.codeplex.com/" target="_blank">PowerShell Community Extensions</a>.</p>
<p>First I wanted to save session names so I&#8217;ll be able to check session content based on file name (ba02.wmv). One place, where the session name is mentioned, is second line of media.js file:</p>
<p><img class="alignnone" title="media.js file content" src="http://powershell.cz/images/quick-file-processing/MMS_MediaJsContent.jpg" alt="" width="846" height="134" /></p>
<p class="code">PS ToBurn:\&gt; Get-ChildItem -Include media.js -Recurse |% { (Get-Content $_)[1] -match &#8216;^{&#8220;title&#8221;:&#8221;(.*?)&#8221;,&#8217; | Out-Null; $matches[1] }<br />
BA01 &#8211; Configuration Manager State of the Union<br />
BA02 &#8211; Configuration Manager 2007 R3: Technical Update<br />
BA03 &#8211; Configuration Manager 2012 &#8211; Technical Overview<br />
BA04 &#8211; Configuration Manager 2012: Application Management (Part 1 of 3)<br />
BA05 &#8211; Configuration Manager 2012: Application Management (Part 2 of 3)<br />
BA06 &#8211; Configuration Manager 2012: Migrating from 2007 to 2012<br />
&#8230;</p>
<p>As I was working in console (I use aliases as much as possible) and wanted to store this list for future check, my actual command was:</p>
<p class="code">PS ToBurn:\&gt; ls -i media.js -r |% { (gc $_)[1] -match &#8216;^{&#8220;title&#8221;:&#8221;(.*?)&#8221;,&#8217; | Out-Null; $matches[1] } | Out-Printer</p>
<p>Voila &#8211; <strong>Out-Printer</strong> useful again <img src='http://powershell.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Second I needed to move video files to my burn folder and rename it.</p>
<p class="code">PS ToBurn:\&gt; ls -i video.wmv -r |% { Move-Item $_ -Destination $(&#8216;ToBurn:\&#8217;+$(Split-path $_.DirectoryName -Leaf)+&#8217;.wmv&#8217;) }</p>
<p>For all WMV files, I moved them to root of ToBurn PSDrive and renamed based on pattern &lt;folder_name&gt;.wmv.</p>
<p>Last point was to remove everything except video files:</p>
<p class="code">PS ToBurn:\&gt; ls * -r |? {$_.name -notlike &#8216;*.wmv&#8217;} | del -force</p>
<p>OK &#8211; then just burn what I just selected and MMS party can begin.</p>
<p><strong>Conclusion:</strong> When I put DVD to my player, it reported: &#8220;Resolution not supported.&#8221; So I used my common solution: notebook + VGA cable.</p>
]]></content:encoded>
			<wfw:commentRss>http://powershell.cz/2011/08/14/quick-file-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

