2015-July Scripting Games Puzzle

Our July 2015 puzzler is designed to make you really think about the PowerShell parser. Normally, you can more or less ignore the parser, because if you’re typing best-practice, long-form code (no aliases, spell out parameter names, etc), the parser deals really well with everything. But knowing how the parser works is useful, because when you get into tricky syntax, the parser can be harder to work with. So we’re going to test the limits of the parser’s patience – and your skills!


The Scripting Games have been re-imagined as a monthly puzzle. We publish puzzles the first Saturday of each month, along with solutions and commentary for the previous month’s puzzle. You can find them all at https://powershell.org/category/announcements/scripting-games/. Many puzzles will include optional challenges, that you can use to really push your skills.

To participate, add your solution to a public Gist (http://gist.github.com; you’ll need a free GitHub account, which all PowerShellers should have anyway). After creating your public Gist, just copy the URL from your browser window and paste it, by itself, as a comment of this post. Only post one entry per person. You are not allowed to come back and post corrected or improved versions. If you do, all of your posts will be ignored. However, remember that you can always go back and edit your Gist. We’ll always pull the most recent one when we display it, so there’s no need to post multiple entries if you want to make an edit.

Don’t forget the main rules and purpose of these monthly puzzles, including the fact that you won’t receive individual scoring or commentary on your entry.

User groups are encouraged to work together on the monthly puzzles. User group leaders should submit their group’s best entry to Ed Wilson, the Scripting Guy, via e-mail, prior to the third Saturday of the month. On the last Saturday of the month, Ed will post his favorite, along with commentary and excerpts from noteworthy entries. The user group with the most “favorite” entries of the year will win a grand prize from PowerShell.org.

Our Puzzle

Write a one-liner that produces the following output (note that property values will be different from computer to computer; that’s fine). 

By definition, a one-liner is a single, long command or pipeline that you type, hitting Enter only at the very end. If it wraps to more than one physical line as you’re typing, that’s OK. But, in order to really test your skill with the parser, try to make your one-liner as short as technically possible while still running correctly.



Try to use no more than one semicolon total in the entire one-liner

Try not to use ForEach-Object or one of its aliases

Write the command so that it could target multiple computers (no error handling needed) if desired

Want to go obscure? Feel free to use aliases and whatever other shortcuts you want to produce a teeny-tiny one-liner.

About Don Jones

Don Jones is a Windows PowerShell MVP, author of several Windows PowerShell books (and other IT books), Co-founder and President/CEO of PowerShell.org, PowerShell columnist for Microsoft TechNet Magazine, PowerShell educator, and designer/author of several Windows PowerShell courses (including Microsoft's). Power to the shell!

77 thoughts on “2015-July Scripting Games Puzzle

  1. Pingback: Scripting Games July 2015 puzzle | Richard Siddaway's Blog

  2. Pingback: 2015 PowerShell Scripting Games have commenced! | Tech, Automation, Life

    1. Don Jones Post author

      That misses the entire point of the monthly puzzles, which is to be able to see how other people approach the problem. Keep in mind that there’s no scoring and no winner. Also keep in mind that you’re only supposed to post ONE entry.

  3. selene v

    GWmi -Class win32_operatingsystem -computername “onecomputername”,”twocomputername” | ft -Property PSComputername,ServicePackMajorVersion,Version, @{Label=”BIOSSerial”; Expression={$_.serialnumber}}

  4. Pingback: My July 2015 Scripting Puzzle Solution | Working Sysadmin

  5. Pingback: The Scripting Games is Back! |

  6. Mukesh Kumar


    In Powershell V2, when i run gwmi win32_OperatingSystem | Select-Object @{Name=”PSComputerName”;Expression={$_.__SERVER}}

    the result is blank. But if i put this in a variable (like $a) : $a=gwmi win32_OperatingSystem | Select-Object @{Name=”PSComputerName”;Expression={$_.__SERVER}}
    , then $a.PSComputerName gives me the value.

    On V3, the command displays value. The difference i notice is PSComputerName is a NoteProperty in V2 while it is an aliasProperty in V3(introduced in V3 only).
    Can i make ” gwmi win32_OperatingSystem | Select-Object @{Name=”PSComputerName”;Expression={$_.__SERVER}} ” return value in V2 ?

  7. Pingback: Philadelphia PowerShell User Group Meeting – August 6th 2015 » PowerShell.org

  8. Pingback: Twin Cities PowerShell 07/14: In Review | halfwaytoinfinite

  9. Pingback: PowerShell MVPs Going Above and Beyond! - The Microsoft MVP Award Program Blog - Site Home - MSDN Blogs

  10. Matt Bloomfield

    Ok, I missed the teeny-tiny bit of the brief. Perhaps this can be an example of how much you can get away with using parentheses and commas.

    This can all be entered on one line without pressing ENTER until the end. No semicolons, no foreach or aliases, and could target multiple computers (1-by-1).

    I’ll document my (long-winded) approach in a blog post, for now here’s the code:


  11. Pingback: 2015-July Scripting Games Wrap-Up » PowerShell.org

  12. Pingback: Scripting Games July 12015 thoughts on the solution | Richard Siddaway's Blog

  13. Pingback: Scripting Games – Puzzle 1 |

  14. Pingback: My Solution: July 2015 PowerShell Scripting Games Puzzle | Mike F Robbins

Comments are closed.