Generic filters
Exact matches only
Filter by Custom Post Type

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 Many puzzles will include optional challenges, that you can use to really push your skills.

To participate, add your solution to a public Gist (; 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

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). 

PSComputerName ServicePackMajorVersion Version  BIOSSerial                                -------------- ----------------------- -------  ----------                                win81                                0 6.3.9600 VMware-56 4d 09 1 71 dd a9 d0 e6 46 9f

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.

Recommend0 recommendationsPublished in Scripting Games

  1. Edit, had mine set to secret gist.

  2. All the comments here should have been hidden, just my opinion.

    • 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. I'm posting mine here but look forward to seeing everyone else's as well!

  4. My try:

    $c=Read-Host ?;gwmi CIM_OperatingSystem -cn $c|select ps*,s*n,v*,@{n='BIOSSerial';e={$_.serialnumber}}

  5. It s Ready..WALAAHH...!!!

  6. GotOne More!

  7. Minor correction for readability:

  8. First (and maybe only) attempt

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

  10. Unfortunately neither of my two computers seem to have a BIOS serial number. Oh well.

  11. And a blog post explaining it, just for fun:

  12. I found it quite funny when testing it my BIOS Serial number came up "To be entered by O.E.M"


    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 ?

  14. Thanks for another round of games!

    • ? It didn't embed. Maybe without the #file...

  15. Sorry for a delayed response.. I came to know about this quiz recently.

  16. Couldn't resist a little user error control... must not be blank input.

  17. I thought it might be helpful to dig into how I arrived at this, so I've written it up here

  18. 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:

  19. That was fun...took about 15 minutes, and I managed to do it without any loops or semicolons.

Skip to toolbar