From the very beginning the Script Center was designed to be an educational resource; our primary mission is to introduce people to system administration scripting. Because our only real goal is to teach people how to script, and because so many of the people who visit the Script Center are new to scripting, that’s required us to adopt a coding style aimed at beginners. For example, a Script Center WMI script might look like this:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
Wscript.Echo colServices.Count
To be honest, that’s more code than we need; after all, these two lines accomplish the exact same task:
Set x = GetObject("winmgmts:").InstancesOf("Win32_Service")
Wscript.Echo x.Count
So why don’t we use the two-line script? That’s easy; experience has shown us that it’s easier for us to explain the longer script, and it’s easier for people to visualize what’s going on when a script is broken into more discrete steps. It’s even better for us to use semi-meaningful variable names like colServices rather than more cryptic names like x.
Of course, just because a given approach is best for the Scripting Guys doesn’t necessarily mean it’s the best for you. And even if it is, well, it’s always interesting (and often extremely helpful) to see how other people approach the exact same problem. Therefore, we’ve added two new features to the 2008 Winter Scripting Games: the Scripting Games Spotlight, where we’ll highlight especially interesting/clever solutions to the Scripting Games events; and the Guest Commentary, where experts in Windows PowerShell and Perl provide solutions to each event in the Advanced Division. (And don’t worry; the Scripting Guys still provide their more detailed solutions and explanations for each event. These solutions are over and above what the Scripting Guys do.)
On the Windows PowerShell side, we are thrilled to present the following PowerShell gurus, who have agreed to help us out as guest commentators:
| • | Richard Siddaway, noted blogger and founder/president of the UK PowerShell User Group. Richard gets the first crack at a Scripting Games solution; he’s working on event 1, Could I Get Your Phone Number?Read Richard’s solution. |
| • | Ben Pearce, creator of the blog Benp’s Guide to Stuff. Ben will be working on event 2, Skating on Thin Ice. Read Ben’s solution. |
| • | Don Jones, book author and founder of both ScriptingAnswers.com and PowerShellCommunity.org. Don will provide a solution to event 3, Instant (Runoff) Winner. Read Don’s solution. |
| • | Ed Wilson, trainer, consultant, book author. Ed has agreed to help us with event 4, Image is Everything. Read Ed’s solution. |
| • | Kirk Munro, Microsoft MVP and author of the blog Poshoholic. Kirk is working on a solution for event 5, You Call That a Strong Password? Read Kirk’s solution. |
| • | Thomas Lee, blogger and prolific contributor to the Community Content on MSDN. Thomas will be handling event 6, Prime Time. Read Thomas’ solution. |
| • | Scott Hanselman, owner of the Web site Scott Hanselman’s ComputerZen.com. Scott is taking care of event 7, Play Ball! Read Scott’s solution. |
| • | Marco Shaw, Microsoft MVP, blogger, and moderator on PowerShellCommunity.org. Marco is helping us out with event 8, Making Beautiful Music. Read Marco’s solution. |
| • | Arnaud Petijean, MVP, co-founder of the French PowerShell Community, and author of a new PowerShell book. Arnaud will be tackling event 9, You’re Twisting My Words. |
| • | /\/\o\/\/, aka The PowerShell Guy, and creator of the PowerTab add-in. /\/\o\/\/ will round out our expert commentary by handling event 10, Blackjack!Read /\/\o\/\/’s solution. |
On the Perl side, Jan Dubois from ActiveState takes on the Herculean task of providing solutions to all 10 events. That’s what we said, too: wow.
Here are links to Jan’s solutions:
| • | |
| • | |
| • | |
| • | |
| • | |
| • | |
| • | |
| • | |
| • | |
| • |
Thank you to all our guest commentators!