Scripting Games 2013: Event 5 Notes

With week 5 in the books, I can see that everyone just continues to grow and show some great submissions. Of course, nothing is perfect and can always show areas of improvement, but trust me, you are all doing an excellent job!

I was hoping to have this article completed prior to now, but between a flight to Tech Ed and forgetting my power cord for the laptop, I am just now getting this accomplished. Better late than never Smile. Luckily, my fellow judges have put together some amazing blogs for this event that you should definitely review as well. So lets get to some of the things that I did and didn’t like.

What I liked

I liked seeing those people that were using Select –Unique or even Sort –Unique to pull out all of the duplicate IP addresses that were in all of the log files. By doing this, it becomes easier to identify all of the IPs rather than trying to figure out which ones are unique manually.

I was intrigued by those you used Import-Csv and then parsing the data with [ipaddress]. Very cool stuff! In fact, one of my tips on the PowerShell Magazine mentioned using [ipaddress] to validate an IP address.  So kudos to those of you who went this route! It shows just how many possibilities there are in solving a given requirement.

 

What I didn’t like

I have seen quite a bit of people using Get-Content to pull in the file data and then piping that into Select-String. While this does work, it isn’t exactly the most efficient way to accomplish this. Instead you should use Get-Content with the –ReadCount of 0 to pull the data as one string to work with. Either way will get you better off.

If you are going to use a regular expression for IP addresses, don’t use the following:

\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\

Ok, I am not talking about how this really doesn’t help for invalid IPs, but then again, we are not validating IP addresses, just looking for them. The problem is that this could actually be shortened down because ideally we are looking for the same items 3 times in a row. Instead take a look at doing something like this:

(\d{1,3}\.){3}\d{1,3}

As we are now down to voting for Event 6, I want to say “Great job!” to everyone that has submitted scripts for 1, 2 or all of the events. I promise that this will do nothing but make all of us better PowerShell scripters by reviewing everyone else’s submissions and by leaving constructive feedback.

About Boe Prox

Microsoft Cloud and Datacenter MVP working as a SQL DBA.
This entry was posted in 2013 Scripting Games Judges Notes, powershell, Scripting Games 2013 and tagged , , , . Bookmark the permalink.

One Response to Scripting Games 2013: Event 5 Notes

  1. Pingback: Scripting Games 2013: Event 5 Notes | PowerShell.org

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s