Hey, Scripting Guy! Opening Ceremonies and 2009 Scripting Games Event 6 Details (Beginner and Advanced; 110-meter hurdles)

Hey, Scripting Guy! Opening Ceremonies and 2009 Scripting Games Event 6 Details (Beginner and Advanced; 110-meter hurdles)

  • Comments 2
  • Likes

2009 Summer Scripting Games

 

Question Hey Scripting Guy! When do the 2009 Summer Scripting Games begin?

--CL

Answer Hello CL,

The 2009 Summer Scripting Games actually begin…well, let's see…yes, they actually begin today! For the last week, we have been revealing the events one day at a time. You can see that information on our blog. The events have been available for a week, but the opening ceremony is today. This year, we have changed some things with the Scripting Games. We are focusing more on learning, and less on competition. As a result, there is no leader board, and no all-time winners group. Everyone who takes the time and extends the effort to write a script or to modify a script, and to share the script with the community is a winner! Just like the thrill you feel after competing in a marathon; it is not dependent upon the time--it is showing up for the race that makes you a winner.

Because we removed the element of competition, it gave us the freedom to expand the games. This year, we have partnered with the group of Microsoft MVPs over at PoshCode to host the 2009 Summer Scripting Games for us. This allows you to review other people's scripts, to vote on the scripts you think are best, and to modify other people's submissions and submit the changes you like. This is how most scripters work. They look for scripts, find something they think is useful, and modify it. The same three steps are allowed in this year's scripting games.

Earlier last week we posted the details for logging onto the PoshCode site and the procedure for submitting scripts. We also posted the Competitor's Pack. We actually debated on the naming convention for this download and toyed with the idea of calling it the Participant's Pack, but in the end we landed on the side of consistency with previous games, rather than ideological purity. Call it what you wish. When you get it, you will need to unzip it to a folder that is easily accessible because you will be using these files in your scripts.

We have two additional resources that will prove vital to you during the Scripting Games. The first is a special Scripting Games Forum, and the second is our Twitter page. The Scripting Games Forum is where you can ask questions about the different events, report issues, and express concerns. Twitter is where you will get real-time, up-to-the-second status information about the Scripting Games and all things related to the Script Center.

Let the games begin!


Beginner Event 6: The 110-meter hurdles

In the 110-meter hurdles, you will be asked to overcome a number of hurdles as you seek to make your script run. Debugging skills will come in handy for this event.  

Event Scenario

Overcoming hurdles, jumping through hoops, walking on a tight rope: Scripting IT pros do it all! We walk a fine line between efficiency and utility. The more efficient the script, the more difficult it is to write, to troubleshoot, and to modify—at times. At other times, inefficient scripts can be just as difficult to write, to troubleshoot, and to modify. When a script finally runs without error, we often feel our work is done.

But what happens when the script runs without error, but is neither efficient, nor inefficient. What happens when the script does not appear to run at all? Now you have some serious hurdles to overcome.  For this event you will use a script that is broken. Here is the VBScript version of the broken script:

Beg_6.vbs

'=================================================================
'
' VBScript:  AUTHOR: Ed Wilson , msft,  6/15/2009
'
' NAME: Beg_6.vbs
'
' problem script for Beginner Event 6.
' 2009 Summer Scripting Games
'=================================================================
Option Explicit
On Error Resume Next
Dim objShell 'Instance of the WshShell object
Dim strDesktop 'Pointer to desktop special folder
Dim objShortCut 'Used to set properties of the shortcut. Comes from using CreateShortcut
Dim objURL 'Used to set properties of webshortcut.
Dim objNotepad
Dim wshNetwork

set objShell = CreateObject("WScript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")

set objShortCut = objShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
objShortCut.TargetPath = WScript.ScriptFullName
objShortCut.WindowStyle = 0
objShortCut.Hotkey = "CTRL+SHIFT+F"
objShortCut.IconLocation = "notepad.exe, 0"
objShortCut.Description = "Shortcut Script"
objShortCut.WorkingDirectory = strDesktop
objShortCut.Save()

Set objShell = CreateObject("Wscript.Shell")
set objURL = objShell.CreateShortcut(strDesktop & "\The Microsoft Scripting Guys.url")
objURL.TargetPath = "http://www.ScriptingGuys.com"
objURL.Save()

Set wshNetwork = CreateObject("WScript.Network")
set objShortCut = objShell.CreateShortcut(strDesktop & "\notepad.lnk")
objShortCut.TargetPath = "notepad.exe"
objShortCut.IconLocation = "notepad.exe, 0"
objShortCut.description = "notepad"
objShortCut.Save

Here is the Windows PowerShell version of the script:

Beg_6.ps1

#==========================================================================
#
# PowerShell:  AUTHOR: Ed Wilson , msft,  6/15/2009
#
# NAME: Beg_6.ps1
#
# COMMENT: Key concepts are listed below:
#1. Uses wscript.shell to create three shortcuts on the desktop. The first is a shortcut
#2. to this actual script. It uses the scriptfullName property to assign the path.
#3. The second is a simple Web site URL shortcut. The third one is a shortcut to
#4. Notepad.
#==========================================================================
$ErrorActionPreference = "SilentlyContinue"
Set-PSDebug -Strict
New-Variable -Name obShell #instance of the wshSHell object
New-Variable -Name strDesktop #pointer to desktop special folder
New-Variable -Name objShortCut #used to set properties of the shortcut. Comes from using createShortCut
New-Variable -Name objURL #used to set properties of webshortcut.
$oShell = New-Object -ComObject ("WScript.Shell")
$strDesktop = $objShell.SpecialFolders.item("Desktop")

$objShortCut = $objShell.CreateShortcut($strDesktop + "\Shortcut Script.lnk")
$objShortCut.TargetPath = $MyInvocation.ScriptName
$objShortCut.WindowStyle = 0
$objShortCut.Hotkey = "CTRL+SHIFT+F"
$objShortCut.IconLocation = "notepad.exe, 2"
$objShortCut.Description = "Shortcut Script"
$objShortCut.WorkingDirectory = $strDesktop
$objShortCut.Save

$wshShell = New-Object -ComObject wscript.shell
$objURL = $objShell.CreateShortcut($strDesktop & "\The Microsoft Scripting Guys.url")
$objURL.TargetPath = "http://www.ScriptingGuys.com"
$objURL.Discription = "Scripting Guys"
$objURL.Save()

$wshNetwork = New-Object -ComObject wscript.network
$objShortCut = $objShell.CreateShortcut($strDesktop + "\notepad.link")
$objShortCut.TargetPath = "notpad.exe"
$objShortCut.IconLocation = "notepad.exe, 0"
$objShortCut.description = "notepad"
$objShortCut.Save()

The scripts are essentially the same, and even have similar errors. We can tell you that whoever wrote these scripts had very little idea about what they were doing. There is more than one error. There are more than two errors. Actually, there are quite a few errors. Troubleshooting is an essential skill for beginning scripters. It is also an essential skill for advanced scripters. As Plato once said, "To script is to troubleshoot." (Okay, we missed that class.)

After you have fixed the script, you will see three shortcuts magically appear on your desktop. They are seen here:

Image of three shortcuts placed on the desktop 

Another part of writing a script is modifying them to make them more efficient. Feel free to tighten up the code once you get it working. Things you might consider is reducing the repetition of certain tasks, making it easier to create more than three shortcuts, or adding additional information to your shortcuts.

 

Advanced Event 6: The 110-meter hurdles

In the 110-meter hurdles event, you will be asked to find out where a particular packet is being held up as you analyze diagnostic information to determine which hop is the fastest.

Event Scenario

Parsing log files is a routine task with IT pros. Whether it is the firewall log, the event log, or some other ad hoc log, you have two choices: do it manually, often using Notepad to read the log file; or figure out a way to automate the parsing of the log.

In this scenario you are a given a network trace file, network trace_adv6.txt from the Competitor's Pack, and are tasked with finding where along the interconnected network systems the slowdown is occurring. We cannot tell you much more than that, as it would spoil the fun. We will tell you this; the file was produced by using the tracert command.

 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • All the Scripting Games links in one location! Let the learning begin. Review Submitted Scripts Event

  • introducing such a topic you'd like to congratulate you've let us know. Have good work.