<?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>MWJ Computing</title>
	<atom:link href="http://www.mwjcomputing.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mwjcomputing.com/blog</link>
	<description>A life lived through digital exploration.</description>
	<lastBuildDate>Mon, 02 Aug 2010 16:56:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Documenting PowerShell Scripts &#8211; Part 1</title>
		<link>http://www.mwjcomputing.com/blog/2010/08/documenting-powershell-scripts-part-1/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/08/documenting-powershell-scripts-part-1/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 16:56:33 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Advanced Functions]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/08/documenting-powershell-scripts-part-1/</guid>
		<description><![CDATA[A “best practice” I follow is I document everything I do in a script. There are times I need to go back to a script years later and need to know exactly what it does. This is the first post in a series on how I document my scripts. Hopefully this helps you. The first [...]]]></description>
			<content:encoded><![CDATA[<p>A “best practice” I follow is I document everything I do in a script. There are times I need to go back to a script years later and need to know exactly what it does. This is the first post in a series on how I document my scripts. Hopefully this helps you.</p>
<p>The first topic we are going to cover is something called “Advanced Functions”. This topic has been covered many times before by other people. I wanted to put my spin on this.</p>
<p>When you use Advanced Functions you add the following line to the first line of your function or script.</p>
<pre><span style="color: #000000">[</span><span style="color: #0000ff">CmdletBinding</span><span style="color: #000000">()]</span></pre>
<p>This line, when used in Windows PowerShell 2.0 scripts or functions, gives you the following cmdlets among other things.</p>
<ul>
<li>Write-Verbose </li>
<li>Write-Debug </li>
</ul>
<p>How does this help me document you ask? </p>
<p>I use Write-Verbose for everything I am doing in a script and function. From assigning variables, changing values, switching in and out of functions, I document EVERYTHING. You can put anything you want in Write-Verbose.</p>
<p>One cool trick I do is the following where it gives you the name of the script you are running when you run it.</p>
<pre><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Running Script: $MyInvocation.MyCommand&quot;</span></pre>
<p>I also add things to my scripts and functions so that when other people run the script, they can see who wrote it and other information.</p>
<pre><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Running Script: $MyInvocation.MyCommand&quot;</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Author: Matt Johnson - email@address&quot;</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Script Version: 1.0&quot;</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Join the SE Michigan PowerShell Script Club&quot;</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Verbose</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-Message</span><span style="color: #000000"> </span><span style="color: #800000">&quot;http://www.michiganpowershell.com&quot;</span></pre>
<p>Now when you run your script or function –verbose you get the added information you placed in your script. The possibilities are endless.</p>
<p>I also use Write-Debug but not as frequently. I use those lines to go into further detail on what I am doing. Something that people running my scripts may not want to see if they want more info.</p>
<p>I encourage you to add the [CmdletBinding()] statement to your PowerShell 2.0 scripts and functions and play around with those two statements. </p>
<p>Up Next: Inline Help</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/08/documenting-powershell-scripts-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What podcasts do you subscribe to?</title>
		<link>http://www.mwjcomputing.com/blog/2010/07/what-podcasts-do-you-subscribe-to/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/07/what-podcasts-do-you-subscribe-to/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 17:03:17 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/07/what-podcasts-do-you-subscribe-to/</guid>
		<description><![CDATA[I was looking to see if there are any more good IT / Security related podcasts out there and figured I would ask the masses. I am non-discriminatory on what I listen to as long as it is good content. I have a decent drive to work and use the opportunity to learn new things. [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking to see if there are any more good IT / Security related podcasts out there and figured I would ask the masses. </p>
<p>I am non-discriminatory on what I listen to as long as it is good content. I have a decent drive to work and use the opportunity to learn new things.</p>
<p>Below is my current list. Feel free to suggest more.</p>
<ul>
<li><a href="http://www.exoticliability.com/" target="_blank">Exotic Liability</a></li>
<li><a href="http://forensic4cast.com/" target="_blank">Forensic 4cast</a></li>
<li><a href="http://www.hak5.org/" target="_blank">Hak5</a></li>
<li><a href="http://www.hanselminutes.com/" target="_blank">Hanselminutes</a></li>
<li><a href="http://edge.technet.com/" target="_blank">Technet Edge</a></li>
<li><a href="http://edge.technet.com/" target="_blank">InfoSec Daily</a></li>
<li><a href="http://www.oxmonline.com/podcast" target="_blank">Official Xbox Magazine</a></li>
<li><a href="http://www.owasp.org/index.php/OWASP_Podcast" target="_blank">OWASP Security Podcast</a></li>
<li><a href="http://packetpushers.net/" target="_blank">Packet Pushers</a></li>
<li><a href="http://www.pauldotcom.com" target="_blank">PauDotCom Security Weekly</a></li>
<li><a href="http://www.powerscripting.net" target="_blank">PowerScripting Podcast</a></li>
<li><a href="http://www.runasradio.com/" target="_blank">RunAs Radio</a></li>
<li><a href="http://www.securabit.com/" target="_blank">SecuraBit</a></li>
<li><a href="http://securityjustice.com/" target="_blank">Security Justice</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/07/what-podcasts-do-you-subscribe-to/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some cool links &#8211; June 29th Edition</title>
		<link>http://www.mwjcomputing.com/blog/2010/06/some-cool-links-june-29th-edition/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/06/some-cool-links-june-29th-edition/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 13:24:05 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/06/some-cool-links-june-29th-edition/</guid>
		<description><![CDATA[I have been way to busy lately to put anything on the blog, but I wanted to share the links below. Hopefully I will start blogging by the end of the week. The EXPTA {blog}: The New Exchange 2007 SP3 Password Reset Tool – Very cool feature of Exchange 2007 SP3. You are now able [...]]]></description>
			<content:encoded><![CDATA[<p>I have been way to busy lately to put anything on the blog, but I wanted to share the links below. Hopefully I will start blogging by the end of the week.</p>
<p><a href="http://www.expta.com/2010/06/new-exchange-2007-sp3-password-reset.html" target="_blank">The EXPTA {blog}: The New Exchange 2007 SP3 Password Reset Tool</a> – Very cool feature of Exchange 2007 SP3. You are now able to force people to change their passwords on login to OWA. This will replace some work arounds that I have implemented. Note this isn’t available in Exchange 2010.</p>
<p><a href="http://support.apple.com/kb/TS3398" target="_blank">iOS 4: Exchange Mail, Contacts, or Calendars may not sync after update</a> – What? My iPhone won’t sync Exchange and is killing my Exchange server? My iPhone isn’t evil! Or is it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/06/some-cool-links-june-29th-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2010 Scripting Games Wrap Up</title>
		<link>http://www.mwjcomputing.com/blog/2010/05/2010-scripting-games-wrap-up/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/05/2010-scripting-games-wrap-up/#comments</comments>
		<pubDate>Mon, 24 May 2010 21:27:18 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/05/2010-scripting-games-wrap-up/</guid>
		<description><![CDATA[Well the expert answers are now being published over on the Hey Scripting Guys blog. So I figured I would write up a little on my experience during the games, how little they may be. I sent in only 3 scripts as life got in the way. Too much school and working. Oh well. I [...]]]></description>
			<content:encoded><![CDATA[<p>Well the expert answers are now being published over on the Hey Scripting Guys blog. So I figured I would write up a little on my experience during the games, how little they may be. </p>
<p>I sent in only 3 scripts as life got in the way. Too much school and working. Oh well. I did however complete 95% of each script but wasn’t happy with the code so I didn’t submit them. I know I should have submitted them anyways, but oh well. This however doesn’t mean I am done working on them. I plan on posting my solutions on my blog as I get time to finish them. (Probably sometime in June.)</p>
<p>The good thing is that I did learn some things and remember a few others. After all, isn’t that the whole reason for the Scripting Games anyways?</p>
<ol>
<li>The first thing I remembered is how cool Tee-Object is. For those of you who don’t know Tee-Object sends what you pass it to both the screen and a file. I am assuming this is based of the tee command in Unix. No matter where it is from, I am going to try to remember to add this to my bag of tricks. See my example below. I am running Get-Process and selecting the first 10. I am then passing that to Tee-Object and saving it to a file and viewing the content at the same time. Very Cool!      <br /><a href="http://www.mwjcomputing.com/blog/wp-content/uploads/2010/05/teeobject51910.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tee-object-51910" border="0" alt="tee-object-51910" src="http://www.mwjcomputing.com/blog/wp-content/uploads/2010/05/teeobject51910_thumb.jpg" width="502" height="294" /></a>       </li>
<li>I learned I was making things to hard for myself. Before the Scripting Games I would use a parameter named DEBUG and an if statement to write extra information to the screen when running a script. Good news! PowerShell v2.0 has a statement you can add to your scripts to force your scripts to recognize the debug parameter. Once you add that you can use the Write-Debug cmdlet. This makes life so much easier. </li>
<li>I remembered that there are tons of different resources. Use them. I can’t stress that enough. Without those resources everything gets exponentially more difficult.</li>
</ol>
<p>There are also some thank you’s that need to go out.</p>
<ol>
<li>The Scripting Guys. I can’t even imagine how much work goes into producing an event like this. Thank you for doing this for the community.</li>
<li>Joel Bennett (Jaykul) for hosting PoshCode and the repository for posting our scripts.</li>
<li>The sponsors of the Scripting Games.      </li>
<ul>
<li><a href="http://bit.ly/2010sgteched">Tech·Ed 2010 North America</a></li>
<li><a href="http://bit.ly/2010sgsponsorposhcode">PoshCode.org</a></li>
<li><a href="http://bit.ly/2010sgsponsortechnet">Microsoft TechNet</a></li>
<li><a href="http://bit.ly/2010sgsponsorsapien">SAPIEN Technologies</a></li>
<li><a href="http://bit.ly/2010sgsponsorquest">Quest Software</a></li>
<li><a href="http://bit.ly/2010sgsponsornsoftware">/n software</a></li>
<li><a href="http://bit.ly/2010sgsponsorsoftwarefx">Software FX</a></li>
<li><a href="http://bit.ly/2010sgsponsor101">101FreeTechBooks.com</a></li>
<li><a href="http://bit.ly/2010sgsponsorshelltools">ShellTools</a></li>
<li><a href="http://bit.ly/2010sgsponsoridera">Idera</a></li>
</ul>
</ol>
<p>Lastly, I want to thank Ed personally for allowing me to write a solution for Advanced Event 4. I can say that has been the highlight of my scripting career.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/05/2010-scripting-games-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting games continue&#8230;.</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/scripting-games-continue/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/scripting-games-continue/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 21:50:43 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/scripting-games-continue/</guid>
		<description><![CDATA[The scripting games have been progressing quite well. PoshCode.org seems to go down sometimes but as we all know we can’t predict the future only respond to things when they happen sometimes. I am still working on some of the advanced scripts and hope to submit them this weekend. Today was event 4. It dealt [...]]]></description>
			<content:encoded><![CDATA[<p>The scripting games have been progressing quite well. PoshCode.org seems to go down sometimes but as we all know we can’t predict the future only respond to things when they happen sometimes.</p>
<p>I am still working on some of the advanced scripts and hope to submit them this weekend. Today was event 4. It dealt with environment variables. Unfortunately I won’t be submitting today’s scripts as I wrote the solution for the advanced event. I was honored that the Scripting Guys allowed me to write a solution. I can only hope they ask me to do it again next year.</p>
<p>You can pick up the beginner event <a href="http://blogs.technet.com/heyscriptingguy/archive/2010/04/29/2010-scripting-games-beginner-event-4.aspx" target="_blank">here</a> and the advanced event <a href="http://blogs.technet.com/heyscriptingguy/archive/2010/04/29/2010-scripting-games-advanced-event-4.aspx" target="_blank">here</a>. </p>
<p>I am working on a few blog posts to hopefully post next week. Until then you are going to have to suffer through some link posts.</p>
<p>Happy Scripting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/scripting-games-continue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2010 Scripting Games Are Here!</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/2010-scripting-games-are-here/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/2010-scripting-games-are-here/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 12:51:19 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/2010-scripting-games-are-here/</guid>
		<description><![CDATA[The 2010 Scripting Games began this morning! You should head over to the Official 2010 Scripting Games Page and get started! Happy Scripting!]]></description>
			<content:encoded><![CDATA[<p>The 2010 Scripting Games began this morning! You should head over to the <a href="http://blogs.technet.com/heyscriptingguy/archive/2010/04/05/2010-scripting-games-all-links-on-one-page.aspx" target="_blank">Official 2010 Scripting Games Page</a> and get started!</p>
<p>Happy Scripting! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/2010-scripting-games-are-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function to check for valid IP</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/function-to-check-for-valid-ip/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/function-to-check-for-valid-ip/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 17:33:53 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/function-to-check-for-valid-ip/</guid>
		<description><![CDATA[Just thought I would share this. I needed to check to see if an IP was valid when going through an excel document. So I wrote a quick function to test to see if it is a valid IP address. You can download this function here. Quick and Simple! Enjoy! function Test-IsValidIP{ param ( [string]$ipAddress [...]]]></description>
			<content:encoded><![CDATA[<p>Just thought I would share this. I needed to check to see if an IP was valid when going through an excel document. So I wrote a quick function to test to see if it is a valid IP address.</p>
<p>You can download this function <a href="http://www.mwjcomputing.com/powershell/test-isvalidip.ps1" target="_blank">here</a>.</p>
<p>Quick and Simple! Enjoy!</p>
<pre><span style="color: #0000ff;">function</span><span style="color: #000000;"> </span><span style="color: #0000ff;">Test</span><span style="color: #ff0000;">-</span><span style="color: #0000ff;">IsValidIP</span><span style="color: #000000;">{
    </span><span style="color: #0000ff;">param</span><span style="color: #000000;"> (
        [</span><span style="color: #0000ff;">string</span><span style="color: #000000;">]</span><span style="color: #800080;">$ipAddress</span><span style="color: #000000;">
    )

    </span><span style="color: #008000;">#Regex Query
</span><span style="color: #000000;">    </span><span style="color: #800080;">$regexQuery</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"^([1-9]|[1-9][0-9]|1[0-9][0-9]`
        |2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]`
        |1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$"</span><span style="color: #000000;">

    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$ipAddress</span><span style="color: #000000;"> </span><span style="color: #ff0000;">-match</span><span style="color: #000000;"> </span><span style="color: #800080;">$regexQuery</span><span style="color: #000000;">){
        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">(</span><span style="color: #0000ff;">$true</span><span style="color: #000000;">)
    } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> {
        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">(</span><span style="color: #0000ff;">$false</span><span style="color: #000000;">)
    }
}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/function-to-check-for-valid-ip/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Are you competing in the Scripting Games? I am!</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/are-you-competing-in-the-scripting-games-i-am/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/are-you-competing-in-the-scripting-games-i-am/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 19:21:23 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/are-you-competing-in-the-scripting-games-i-am/</guid>
		<description><![CDATA[I am and let me explain why. The Scripting Games that are put on by the Microsoft Scripting Guys is a great opportunity to learn, advance or prove you know your stuff when it comes to scripting. I participated the last few times that the games were ran and I loved it. Every minute of [...]]]></description>
			<content:encoded><![CDATA[<p>I am and let me explain why. The Scripting Games that are put on by the Microsoft Scripting Guys is a great opportunity to learn, advance or prove you know your stuff when it comes to scripting. I participated the last few times that the games were ran and I loved it. Every minute of it. </p>
<p>The scripting games start on April 26th and go to May 7th. I know I am encouraging everyone in the <a href="http://michiganpowershell.com/" target="_blank">SE Michigan PowerShell Script</a> club to participate and hopefully you do to!</p>
<p>There are 10 events in both an beginner and advanced categories. This year there are two languages that the scripts can be written in. Those are PowerShell and VBScript. (I heard that this is the last year for VBScript. Boohoo! VBScript will always have a place in my heart but change is good. And besides PowerShell is awesome!) These events encompass tasks that can help you with your day to day job. Looking at the 2010 Scripting Games Study guide gives us a hint at what the events might entail. From working with text files and folders to using WMI information I am sure that everyone will find this to be fun and challenging. </p>
<p>When you are done writing your script, you can post it up along with everyone else's submission on the special Scripting Games section of the <a href="http://poshcode.org" target="_blank">PoshCode.org</a> website. That site is at <a href="http://2010sg.poshcode.org">http://2010sg.poshcode.org</a>. Very cool of PoshCode to do this if I do say so.</p>
<p>At the end of each event scripting experts will provide commentary on how they tackled the script and their solution. This is a great opportunity to learn from some of the best in the scripting community. You should note however that there are almost always many ways to solve a problem, but what some of the experts do is amazing in how well their scripts are written. </p>
<p>So with all that being said, I urge you to compete. Oh I forgot to mention there will be prizes? According to the FAQ they will be having 11 drawings, which amounts to one drawing per day and a grand prize. All you have to do to be eligible is to submit a script for the event! Now how easy is that? And who doesn’t love prizes? I know I do.</p>
<p>What do you do next? Well there are a few things you can do to get prepared.</p>
<ol>
<li>Register to compete! You can do this by going to <a href="http://2010sg.poshcode.org">http://2010sg.poshcode.org</a>. Make sure you do this so you can hit the round running on April 26th, 2010.</li>
<li>Read the Frequently Asked Questions. You can find them at <a href="http://bit.ly/2010sgdetails">http://bit.ly/2010sgdetails</a></li>
<li>Use the study guide the Scripting Guys so graciously provided at <a href="http://bitl.ly/2010sgstudyguide">http://bitl.ly/2010sgstudyguide</a>.</li>
<li>Read the Scripting Guys Blog and follow along as the Scripting Wife learns PowerShell! Their blog is at <a title="http://blogs.technet.com/heyscriptingguy/default.aspx" href="http://blogs.technet.com/heyscriptingguy/default.aspx">http://blogs.technet.com/heyscriptingguy/default.aspx</a></li>
<li>If you have your own website or blog, put the 2010 Scripting Games badge on your site so that everyone knows you are competing and you can help bring in more people! You can get that at <a href="http://bit.ly/2010sggrabbadge">http://bit.ly/2010sggrabbadge</a>. </li>
<li>If you use twitter or Facebook, make sure you add the Twibbon for your profile picture! You can get the twibbon at <a title="http://twibbon.com/join/2010-scripting-games" href="http://twibbon.com/join/2010-scripting-games">http://twibbon.com/join/2010-scripting-games</a>. </li>
</ol>
<p>I hope to see you on the “Scripting Field”.</p>
<p>Happy Scripting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/are-you-competing-in-the-scripting-games-i-am/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate time with a format of hh:mm:ss using RegEx</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/validate-time-with-a-format-of-hhmmss-using-regex/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/validate-time-with-a-format-of-hhmmss-using-regex/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 17:36:52 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/validate-time-with-a-format-of-hhmmss-using-regex/</guid>
		<description><![CDATA[Here are two quick ways to validate an entered date. Both examples work with PowerShell 2.0 but only the first one works with PowerShell 1.0. The following is a RegEx string to validate input in the format of hh:mm:ss. [01][0-9]:[0-6][0-9]:[0-6][0-9] We can use a simple if statement to validate the time as seen below $time [...]]]></description>
			<content:encoded><![CDATA[<p>Here are two quick ways to validate an entered date. Both examples work with PowerShell 2.0 but only the first one works with PowerShell 1.0.</p>
<p>The following is a RegEx string to validate input in the format of hh:mm:ss.</p>
<p>[01][0-9]:[0-6][0-9]:[0-6][0-9]</p>
<p>We can use a simple if statement to validate the time as seen below</p>
<pre><span style="color: #800080">$time</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;22:33:22&quot;</span><span style="color: #000000">

</span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$time</span><span style="color: #000000"> </span><span style="color: #ff0000">-match</span><span style="color: #000000"> </span><span style="color: #800000">&quot;[01][0-9]:[0-6][0-9]:[0-6][0-9]&quot;</span><span style="color: #000000">){
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #0000ff">$true</span><span style="color: #000000">
} </span><span style="color: #0000ff">else</span><span style="color: #000000">{
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #0000ff">$false</span><span style="color: #000000">
}</span></pre>
<p>Pat Richard pointed out that we can do this with a few less lines of code, so you can choose what way you want to do this. He used the –match switch against the variable itself. Here is what he suggested:</p>
<pre><span style="color: #800080">$time</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;22:33:22&quot;</span><span style="color: #000000">
</span><span style="color: #800080">$time</span><span style="color: #000000"> </span><span style="color: #ff0000">-match</span><span style="color: #000000"> </span><span style="color: #800000">&quot;[01][0-9]:[0-6][0-9]:[0-6][0-9]&quot;</span></pre>
<p>With PowerShell 2.0, we can validate it when it is entered as a parameter by adding the following lines into your param() statement replacing the variable $userTime with the name of your variable.</p>
<pre><span style="color: #000000">[</span><span style="color: #0000ff">ValidatePattern</span><span style="color: #000000">(</span><span style="color: #800000">&quot;[01][0-9]:[0-6][0-9]:[0-6][0-9]&quot;</span><span style="color: #000000">)]
[</span><span style="color: #0000ff">string</span><span style="color: #000000">]</span><span style="color: #800080">$userTime</span></pre>
<p>The following function validates time in the format of hh:mm:ss. It can also be downloaded <a href="http://www.mwjcomputing.com/powershell/test-isvalidtime.ps1" target="_blank">here</a>.</p>
<pre><span style="color: #0000ff">function</span><span style="color: #000000"> </span><span style="color: #5f9ea0">Test-IsValidTime</span><span style="color: #000000"> {
    </span><span style="color: #008000">&lt;#
    .</span><span style="color: #008000">SYNOPSIS</span><span style="color: #008000">
        </span><span style="color: #008000">Checks</span><span style="color: #008000"> </span><span style="color: #008000">to</span><span style="color: #008000"> </span><span style="color: #008000">see</span><span style="color: #008000"> </span><span style="color: #008000">if</span><span style="color: #008000"> </span><span style="color: #008000">value</span><span style="color: #008000"> </span><span style="color: #008000">entered</span><span style="color: #008000"> </span><span style="color: #008000">is</span><span style="color: #008000"> </span><span style="color: #008000">in</span><span style="color: #008000"> </span><span style="color: #008000">valid</span><span style="color: #008000"> </span><span style="color: #008000">format</span><span style="color: #008000">.

    .</span><span style="color: #008000">DESCRIPTION</span><span style="color: #008000">
        </span><span style="color: #008000">This</span><span style="color: #008000"> </span><span style="color: #008000">function</span><span style="color: #008000"> </span><span style="color: #008000">tests</span><span style="color: #008000"> </span><span style="color: #008000">to</span><span style="color: #008000"> </span><span style="color: #008000">see</span><span style="color: #008000"> </span><span style="color: #008000">if</span><span style="color: #008000"> </span><span style="color: #008000">the</span><span style="color: #008000"> </span><span style="color: #008000">date</span><span style="color: #008000"> </span><span style="color: #008000">entered</span><span style="color: #008000"> </span><span style="color: #008000">in</span><span style="color: #008000"> </span><span style="color: #008000">hh</span><span style="color: #008000">:</span><span style="color: #008000">mm</span><span style="color: #008000">:</span><span style="color: #008000">ss</span><span style="color: #008000"> </span><span style="color: #008000">format</span><span style="color: #008000"> </span><span style="color: #008000">is</span><span style="color: #008000"> </span><span style="color: #008000">a</span><span style="color: #008000"> </span><span style="color: #008000">valid</span><span style="color: #008000"> </span><span style="color: #008000">time</span><span style="color: #008000">.

    .</span><span style="color: #008000">PARAMETER</span><span style="color: #008000">  </span><span style="color: #008000">time</span><span style="color: #008000">
        </span><span style="color: #008000">Time</span><span style="color: #008000"> </span><span style="color: #008000">entered</span><span style="color: #008000"> </span><span style="color: #008000">in</span><span style="color: #008000"> </span><span style="color: #008000">format</span><span style="color: #008000"> </span><span style="color: #008000">of</span><span style="color: #008000"> </span><span style="color: #008000">hh</span><span style="color: #008000">:</span><span style="color: #008000">mm</span><span style="color: #008000">:</span><span style="color: #008000">ss</span><span style="color: #008000">.

    .</span><span style="color: #008000">EXAMPLE</span><span style="color: #008000">
        </span><span style="color: #008000">PS</span><span style="color: #008000"> </span><span style="color: #008000">C</span><span style="color: #008000">:\&gt; </span><span style="color: #008000">Test</span><span style="color: #008000">-</span><span style="color: #008000">IsValidTime</span><span style="color: #008000"> -</span><span style="color: #008000">time</span><span style="color: #008000"> '</span><span style="color: #008000">12</span><span style="color: #008000">:</span><span style="color: #008000">34</span><span style="color: #008000">:</span><span style="color: #008000">56</span><span style="color: #008000">'

    .</span><span style="color: #008000">INPUTS</span><span style="color: #008000">
        </span><span style="color: #008000">System</span><span style="color: #008000">.</span><span style="color: #008000">String</span><span style="color: #008000">

    .</span><span style="color: #008000">OUTPUTS</span><span style="color: #008000">
        </span><span style="color: #008000">System</span><span style="color: #008000">.</span><span style="color: #008000">Boolean</span><span style="color: #008000">

    .</span><span style="color: #008000">NOTES</span><span style="color: #008000">
        </span><span style="color: #008000">This</span><span style="color: #008000"> </span><span style="color: #008000">function</span><span style="color: #008000"> </span><span style="color: #008000">was</span><span style="color: #008000"> </span><span style="color: #008000">written</span><span style="color: #008000"> </span><span style="color: #008000">by</span><span style="color: #008000"> </span><span style="color: #008000">Matt</span><span style="color: #008000"> </span><span style="color: #008000">Johnson</span><span style="color: #008000"> </span><span style="color: #008000">of</span><span style="color: #008000"> </span><span style="color: #008000">the</span><span style="color: #008000"> </span><span style="color: #008000">SE</span><span style="color: #008000"> </span><span style="color: #008000">Michigan</span><span style="color: #008000"> </span><span style="color: #008000">PowerShell</span><span style="color: #008000"> </span><span style="color: #008000">Script</span><span style="color: #008000"> </span><span style="color: #008000">Club</span><span style="color: #008000">.

    .</span><span style="color: #008000">LINK</span><span style="color: #008000">
        </span><span style="color: #008000">http</span><span style="color: #008000">://</span><span style="color: #008000">www</span><span style="color: #008000">.</span><span style="color: #008000">mwjcomputing</span><span style="color: #008000">.</span><span style="color: #008000">com</span><span style="color: #008000">/</span><span style="color: #008000">blog</span><span style="color: #008000">/

    .</span><span style="color: #008000">LINK</span><span style="color: #008000">
        </span><span style="color: #008000">http</span><span style="color: #008000">://</span><span style="color: #008000">www</span><span style="color: #008000">.</span><span style="color: #008000">michiganpowershell</span><span style="color: #008000">.</span><span style="color: #008000">com</span><span style="color: #008000">/

    #&gt;</span><span style="color: #000000">

    </span><span style="color: #0000ff">param</span><span style="color: #000000"> (
    [</span><span style="color: #0000ff">string</span><span style="color: #000000">]</span><span style="color: #800080">$time</span><span style="color: #000000">
    )

    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$time</span><span style="color: #000000"> </span><span style="color: #ff0000">-match</span><span style="color: #000000"> </span><span style="color: #800000">&quot;[01][0-9]:[0-6][0-9]:[0-6][0-9]&quot;</span><span style="color: #000000">){
        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">$true</span><span style="color: #000000">
    } </span><span style="color: #0000ff">else</span><span style="color: #000000">{
        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">$false</span><span style="color: #000000">
    }

} </span><span style="color: #008000">#End Function Test-IsValidTime</span></pre>
<p>&#160;</p>
<p>Happy Scripting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/validate-time-with-a-format-of-hhmmss-using-regex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Script to modify window for PowerShell demo</title>
		<link>http://www.mwjcomputing.com/blog/2010/04/script-to-modify-window-for-powershell-demo/</link>
		<comments>http://www.mwjcomputing.com/blog/2010/04/script-to-modify-window-for-powershell-demo/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 15:31:20 +0000</pubDate>
		<dc:creator>Matt Johnson</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.mwjcomputing.com/blog/2010/04/script-to-modify-window-for-powershell-demo/</guid>
		<description><![CDATA[When I do PowerShell demos, I want my screen to have some default characteristics. The script below is the one I started using when I do a PowerShell demo for co-workers, friends or the SE Michigan PowerShell Script Club. Feel free to tailor it to your liking! You can download this script here. Happy Scripting! [...]]]></description>
			<content:encoded><![CDATA[<p>When I do PowerShell demos, I want my screen to have some default characteristics. The script below is the one I started using when I do a PowerShell demo for co-workers, friends or the <a href="http://www.michiganpowershell.com/" target="_blank">SE Michigan PowerShell Script Club</a>. Feel free to tailor it to your liking! </p>
<p>You can download this script <a href="http://www.mwjcomputing.com/powershell/set-powershelldemo.ps1" target="_blank">here</a>.</p>
<p>Happy Scripting!</p>
<pre><span style="color: #008000">######################################################
# Script Name: set-powershelldemo.ps1
# Written By: Matt Johnson - powershell@mwjcomputing.com
# Revision Date: 4/12/2010
# Version: 2.0
# Version History:
#  - 1.0: Inital Script
#  - 2.0: Added host info switch and display
# Description: This script sets the window for the demo.
# Command Line: ./set-powershelldemo.ps1
# Example 1: ./set-powershelldemo.ps1
# Example 2: ./set-powershelldemo.ps1 -displayHost
######################################################
</span><span style="color: #0000ff">param</span><span style="color: #000000">(
    [</span><span style="color: #0000ff">switch</span><span style="color: #000000">]</span><span style="color: #800080">$displayHost</span><span style="color: #000000">
)

</span><span style="color: #008000"># Get UserInterface Object
</span><span style="color: #800080">$userInterface</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> (</span><span style="color: #5f9ea0">Get-Host</span><span style="color: #000000">)</span><span style="color: #000000">.</span><span style="color: #8b4513">UI</span><span style="color: #000000">.</span><span style="color: #8b4513">RawUI</span><span style="color: #000000">

</span><span style="color: #008000"># Set Window Title
</span><span style="color: #800080">$userInterface</span><span style="color: #000000">.</span><span style="color: #8b4513">WindowTitle</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;MWJ Computing PowerShell Demo&quot;</span><span style="color: #000000">

</span><span style="color: #008000"># Set Window Size
</span><span style="color: #800080">$windowSize</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$userInterface</span><span style="color: #000000">.</span><span style="color: #8b4513">WindowSize</span><span style="color: #000000">
</span><span style="color: #800080">$windowSize</span><span style="color: #000000">.</span><span style="color: #8b4513">Width</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">120</span><span style="color: #000000">
</span><span style="color: #800080">$windowSize</span><span style="color: #000000">.</span><span style="color: #8b4513">Height</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">50</span><span style="color: #000000">
</span><span style="color: #800080">$userInterface</span><span style="color: #000000">.</span><span style="color: #8b4513">WindowSize</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$windowSize</span><span style="color: #000000">

</span><span style="color: #008000"># Check for admin script
</span><span style="color: #800080">$wid</span><span style="color: #ff0000">=</span><span style="color: #000000">[</span><span style="color: #8b4513">System.Security.Principal.WindowsIdentity</span><span style="color: #000000">]</span><span style="color: #000000">::</span><span style="color: #8b4513">GetCurrent</span><span style="color: #000000">()
</span><span style="color: #800080">$prp</span><span style="color: #ff0000">=</span><span style="color: #5f9ea0">new-object</span><span style="color: #000000"> </span><span style="color: #8b4513">System.Security.Principal.WindowsPrincipal</span><span style="color: #000000">(</span><span style="color: #800080">$wid</span><span style="color: #000000">)
</span><span style="color: #800080">$adm</span><span style="color: #ff0000">=</span><span style="color: #000000">[</span><span style="color: #8b4513">System.Security.Principal.WindowsBuiltInRole</span><span style="color: #000000">]</span><span style="color: #000000">::</span><span style="color: #8b4513">Administrator</span><span style="color: #000000">
</span><span style="color: #800080">$IsAdmin</span><span style="color: #ff0000">=</span><span style="color: #800080">$prp</span><span style="color: #000000">.</span><span style="color: #8b4513">IsInRole</span><span style="color: #000000">(</span><span style="color: #800080">$adm</span><span style="color: #000000">)

</span><span style="color: #008000"># Check to see if admin, if is change background to red.
</span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$IsAdmin</span><span style="color: #000000">){
    (</span><span style="color: #5f9ea0">get-host</span><span style="color: #000000">)</span><span style="color: #000000">.</span><span style="color: #8b4513">UI</span><span style="color: #000000">.</span><span style="color: #8b4513">RawUI</span><span style="color: #000000">.</span><span style="color: #0000ff">Backgroundcolor</span><span style="color: #ff0000">=</span><span style="color: #800000">&quot;DarkRed&quot;</span><span style="color: #000000">
}

</span><span style="color: #008000"># Set Location to c:\fso
</span><span style="color: #5f9ea0">Set-Location</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-path</span><span style="color: #000000"> </span><span style="color: #800000">'</span><span style="color: #008000; text-decoration: underline">C:\fso</span><span style="color: #800000">'</span><span style="color: #000000">

</span><span style="color: #008000"># Clear Screen
</span><span style="color: #0000ff">Clear</span><span style="color: #000000">

</span><span style="color: #008000"># Display Welcome Message
</span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Welcome to the MWJ Computing PowerShell Demo.&quot;</span><span style="color: #5f9ea0">`</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #5f9ea0">`</span><span style="color: #000000">
    </span><span style="color: #800000">&quot;For more information, please visit http://www.mwjcomputing.com/blog/.&quot;</span><span style="color: #000000"> </span><span style="color: #5f9ea0">`</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
</span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Happy Scripting!&quot;</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">

</span><span style="color: #008000"># Check for DiplayHost switch.
</span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$displayHost</span><span style="color: #000000">){
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;&quot;</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;UserName: $env:USERNAME&quot;</span><span style="color: #000000"> </span><span style="color: #5f9ea0">`</span><span style="color: #000000">
        </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;HostName: $env:COMPUTERNAME&quot;</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">
        </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;DomainName: $env:USERDNSDOMAIN&quot;</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">
        </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Date: $(Get-Date)&quot;</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
    </span><span style="color: #5f9ea0">Write-Host</span><span style="color: #000000"> </span><span style="color: #5f9ea0">-object</span><span style="color: #000000"> </span><span style="color: #800000">&quot;Execution Policy: $(Get-ExecutionPolicy)&quot;</span><span style="color: #000000"> </span><span style="color: #5f9ea0">`</span><span style="color: #000000">
        </span><span style="color: #5f9ea0">-foregroundcolor</span><span style="color: #000000"> </span><span style="color: #0000ff">Yellow</span><span style="color: #000000">
}
 </span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mwjcomputing.com/blog/2010/04/script-to-modify-window-for-powershell-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
