<?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>brain &#124; get-content</title>
	<atom:link href="http://hatryingoutthings.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hatryingoutthings.wordpress.com</link>
	<description>mostly PowerShell</description>
	<lastBuildDate>Sun, 10 Jan 2010 21:03:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hatryingoutthings.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/a55f9b38d15f1d9e4881ecb030e805fc?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>brain &#124; get-content</title>
		<link>http://hatryingoutthings.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hatryingoutthings.wordpress.com/osd.xml" title="brain &#124; get-content" />
	<atom:link rel='hub' href='http://hatryingoutthings.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Writing a PowerShell script: What&#8217;s the right tool for the job?</title>
		<link>http://hatryingoutthings.wordpress.com/2010/01/10/writing-a-powershell-script-whats-the-right-tool-for-the-job/</link>
		<comments>http://hatryingoutthings.wordpress.com/2010/01/10/writing-a-powershell-script-whats-the-right-tool-for-the-job/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 20:05:27 +0000</pubDate>
		<dc:creator>holgeradam</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://hatryingoutthings.wordpress.com/?p=35</guid>
		<description><![CDATA[PowerShell is becoming more and more popular among administrators and IT professionals. One great thing about PowerShell is the easy-to-learn syntax which quickly leads users to writing their own scripts. And that quickilyraises a question: What is the best editor to write scripts with? This post gives an overview of some ISEs and their capabilities. PowerShell [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hatryingoutthings.wordpress.com&amp;blog=11101731&amp;post=35&amp;subd=hatryingoutthings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>PowerShell is becoming more and more popular among administrators and IT professionals. One great thing about PowerShell is the easy-to-learn syntax which quickly leads users to writing their own scripts. And that quickilyraises a question: What is the best editor to write scripts with? This post gives an overview of some ISEs and their capabilities.</p>
<p><strong>PowerShell ISE</strong></p>
<p>PowerShell ISE was introdced with PowerShell v2 and provides a scripting environment without the need to install additional software. It combines a a script editor with syntax highlight, a PowerShell prompt and a separate output window. PS ISE is capable of debugging scripts and functions providing the basics like breakpoints and single steps. Unfortunately there is no extra view for the variables and their current values. Those are revealed through mouseovers, which makes a comparison of two values or copy &amp; paste impossible. Another discomfort is the fact that the <a href="http://blogs.technet.com/heyscriptingguy/archive/2010/01/04/hey-scripting-guy-january-4-2010.aspx" target="_blank"><span style="font-family:Consolas;">exit</span> command in a script closes PowerShell ISE</a> as well.</p>
<p style="text-align:center;"><a href="http://hatryingoutthings.files.wordpress.com/2010/01/powershell_ise1.jpg" target="_blank"><img class="aligncenter size-medium wp-image-53" title="powershell_ise" src="http://hatryingoutthings.files.wordpress.com/2010/01/powershell_ise1.jpg?w=300&#038;h=196" alt="PowerShell ISE" width="300" height="196" /></a></p>
<p>PowerShell can be customized by up to four profiles. PS ISE adds one to modify its command prompt: <span style="font-family:Consolas;">Microsoft.PowerShellISE_profile.ps1</span> can be used like the standard PowerShell profiles for the current user or all users, just put in the same <a href="http://msdn.microsoft.com/en-us/library/bb613488%28VS.85%29.aspx" target="_blank">location</a>. More customization is available through modules like IsePack, which is part of <a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank">PowerShell Pack</a>.</p>
<p>PowerShell ISE is included in Windows 7 and Server 2008 R2 and the <a href="http://support.microsoft.com/kb/968929" target="_blank">Windows Management Framework</a> for other OS versions.</p>
<p><strong>PowerGUI</strong></p>
<p><a href="http://powergui.org/" target="_blank">PowerGUI</a> is a free tool created by PowerShell community members. It has been around for a while filling the void that PowerShell v1 left regarding an ISE. PowerGUI contains a script editor, but it offers much more than that. As the name suggests it offers a GUI for administrative tasks run by PowerShell in the background. The commands or scripts behind each task can be viewed and analyzed, which is great opportunity to learn using PowerShell. The task list can be extended by creating or downloading so called <a href="http://powergui.org/kbcategory.jspa?categoryID=21" target="_blank">PowerPacks</a>.</p>
<p style="text-align:center;"><a href="http://hatryingoutthings.files.wordpress.com/2010/01/powergui.jpg" target="_blank"><img class="aligncenter size-medium wp-image-52" title="powergui" src="http://hatryingoutthings.files.wordpress.com/2010/01/powergui.jpg?w=300&#038;h=196" alt="" width="300" height="196" /></a></p>
<p>The script editor offers syntax highlighting, auto-completion, a PowerShell prompt (with auto-completion as well) and an input box to pass parameters to the current script. To ease script creation the editor supports code snippets. Snippets are <a href="http://msdn.microsoft.com/en-us/library/ms379562%28VS.80%29.aspx" target="_blank">standardized xml files</a> that were created to increase developer productivity in Visual Studio. There are quite a number of snippets available in PowerGUI and <a href="http://www.powergui.org/entry.jspa?externalID=2472&amp;categoryID=299" target="_blank">online</a>. They are a great way of shortcutting the typing of common script constructs or quickly creating the skeleton of a function or module. And of course there is a debugger for your scripts and functions including a variable window to monitor the script&#8217;s variables state during runtime.</p>
<p>You should definitely give PowerGUI a try, regardless if you&#8217;re new to PowerShell or already a scripting expert.</p>
<p><strong>PowerShell Plus</strong></p>
<p>Another option for the avid PowerShell user is the commercial <a href="http://www.idera.com/Products/PowerShell/PowerShell-Plus/" target="_blank">PowerShell Plus by Idera</a>. It&#8217;s centered around an interactive PowerShell console, offering an overview of  variables in the current session, a graphical history and a QuickClick library that contains one-liners and scripts for a huge number of administrative tasks. The idea is similar to that of PowerGUI and the PowerPacks, but PowerShell Plus puts the QuickClick bits directly into the command prompt to either run it or modify it before executing it.</p>
<p>The script editor is comparable to PowerGUI&#8217;s editor, containing syntax highlighting, auto-completion and the standard debugging features. In addition the debugger can be configured to run your script in slow motion executing each statement and then pausing for a configurable amount of time, which enables stepping through each line of a script without hitting a key for every step. If you feel like sharing you can upload your scripts into a hosted library and download scripts from other users, too. The scripts are organized in categories and can be shared or downloaded in the editor. No need to start your browser or copy files in Explorer.</p>
<p>Like PowerGUI PowerShell Plus supports snippets for your scripts and helps creating your own snippets by saving parts of your scripts as a snippet. You can even select which parts are parameters and have to be filled by the user inserting the snippet. Security enthusiasts will be pleased to see that the editor also supports signing scripts with automatic update after a script modification. Last but not least the editor supports a number of other file formats including VBScript and C#.</p>
<p>PowerShell Plus is available as a 14 trial version. If you&#8217;re looking for a professional scripting environment you should give it a try.</p>
<p><strong>Still haven&#8217;t found, what you&#8217;re looking for?</strong></p>
<p>There are other editors and scripting environments available like <a href="http://www.powershellanalyzer.com" target="_blank">PowerShell Analyzer</a> and <a href="http://www.primaltools.com/products/info.asp?p=PrimalScript" target="_blank">PrimalScript</a><a href="http://www.primaltools.com/downloads/communitytools/"></a>. Or if you&#8217;re the editor and PowerShell console guy you might be interested in <a href="http://www.primaltools.com/downloads/communitytools/" target="_blank">PrimalPad</a> or extending <a href="http://notepad-plus.sourceforge.net/de/site.htm" target="_blank">Notepad++</a> with  PowerShell <a href="http://poshcode.org/notepad++lexer" target="_blank">syntax highlighting</a> and <a href="http://blog.koenvermoesen.be/2008/05/08/powershell-auto-completion-for-notepad" target="_blank">auto-completion</a>.</p>
<p>That doesn&#8217;t satisfy you, either? How about <a href="http://dougfinke.com/blog/index.php/2009/09/02/how-to-host-powershell-in-a-wpf-application" target="_blank">writing your own scripting environment</a> then?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hatryingoutthings.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hatryingoutthings.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hatryingoutthings.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hatryingoutthings.wordpress.com&amp;blog=11101731&amp;post=35&amp;subd=hatryingoutthings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hatryingoutthings.wordpress.com/2010/01/10/writing-a-powershell-script-whats-the-right-tool-for-the-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/77d744ddebc8dec9c14484339db581fa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">holgeradam</media:title>
		</media:content>

		<media:content url="http://hatryingoutthings.files.wordpress.com/2010/01/powershell_ise1.jpg?w=300" medium="image">
			<media:title type="html">powershell_ise</media:title>
		</media:content>

		<media:content url="http://hatryingoutthings.files.wordpress.com/2010/01/powergui.jpg?w=300" medium="image">
			<media:title type="html">powergui</media:title>
		</media:content>
	</item>
		<item>
		<title>How many lines of code are there, really?</title>
		<link>http://hatryingoutthings.wordpress.com/2009/12/25/how-many-lines-of-code-are-there-really/</link>
		<comments>http://hatryingoutthings.wordpress.com/2009/12/25/how-many-lines-of-code-are-there-really/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 11:37:42 +0000</pubDate>
		<dc:creator>holgeradam</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://hatryingoutthings.wordpress.com/2009/12/25/how-many-lines-of-code-are-there-really/</guid>
		<description><![CDATA[Matt Manela recently posted a nice PowerShell one-liner to count the lines in your project. But not all of these lines are actual code or relevant for production, a fair amount of text contains white lines and comments. Fortunately white lines are automatically ignored by Measure-Object, unfortunately comments are not. So to find out how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hatryingoutthings.wordpress.com&amp;blog=11101731&amp;post=1&amp;subd=hatryingoutthings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Matt Manela recently posted a nice PowerShell one-liner to <a href="http://blogs.msdn.com/matt/archive/2009/12/11/count-the-number-of-lines-in-your-project-with-one-line-of-powershell.aspx" target="_blank">count the lines in your project</a>. But not all of these lines are actual code or relevant for production, a fair amount of text contains white lines and comments. Fortunately white lines are automatically ignored by <span style="font-family:Consolas;">Measure-Object</span>, unfortunately comments are not. So to find out how much of the project&#8217;s amount is real code these lines need to be ignored, too.</p>
<p><span style="font-family:Consolas;">Measure-Object</span> itself does not provide functionality to filter lines by their content, hence it needs to receive only the lines that need to be measured. If you&#8217;re using C++ or C#, comments start with <span style="font-family:Consolas;">//</span>, which gives us a pattern of lines to exclude. <span style="font-family:Consolas;">Get-Content</span> outputs each source code file as an array of <span style="font-family:Consolas;">System.String</span> objects, which own the <span style="font-family:Consolas;">StartsWith(String)</span> method.<br />
First let&#8217;s save all of the project&#8217;s content into a variable to reuse it later.</p>
<p><span style="font-family:Consolas;background-color:Gainsboro;">$LinesTotal = Get-ChildItem . -recurse -include *.cs, *.cpp, *.h | Get-Content</span></p>
<p>Before we count this pile of lines we&#8217;ll sort out all lines that start with <span style="font-family:Consolas;">//</span>. This does not remove all comments, yet. Most of the time the <span style="font-family:Consolas;">//</span> is indented and preceeded by blanks or tabs. Therefore to remove all lines of comments we have to trim every line.</p>
<p><span style="font-family:Consolas;background-color:Gainsboro;">$LinesCode = $LinesTotal | ForEach-Object {$_.Trim()} | ForEach-Object {if($_.StartsWith(&#8220;//&#8221;)){$_}}</span></p>
<p>Now to find out how much code there really is, we measure the pure lines of code.</p>
<p><span style="font-family:Consolas;background-color:Gainsboro;">$NumLinesCode = ($LinesCode | Measure-Object -Line).Lines</span></p>
<p>Since we have stored the original amount of lines including the comments, we can use these to determine the amount of comments in relation to pure code.</p>
<p><span style="font-family:Consolas;background-color:Gainsboro;">$NumLinesTotal = ($LinesTotal | Measure-Object -Line).Lines<br />
$NumLinesCode / $NumLinesTotal</span></p>
<p>This can be a useful indicator for too much comments in the code or oversized function descriptions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hatryingoutthings.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hatryingoutthings.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hatryingoutthings.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hatryingoutthings.wordpress.com&amp;blog=11101731&amp;post=1&amp;subd=hatryingoutthings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hatryingoutthings.wordpress.com/2009/12/25/how-many-lines-of-code-are-there-really/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/77d744ddebc8dec9c14484339db581fa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">holgeradam</media:title>
		</media:content>
	</item>
	</channel>
</rss>
