Assign a list of processes to a variable and output it to the console

Hello everyone! The Brain Teaser series continues.

First, we need to announce the winner of the previous brain teaser. We got a lot of answers, but only three of them fulfilled all requirements ( the answers that use -split operator, the Split() method, or regex return the String objects, not System.Char objects). Bartek, Jaykul, and John Ludlow have had the correct answers.

And the winner is… Bartek.

The editors of PowerShell Magazine think that his solution–“PowerShell”.GetEnumerator()–deserves the prize.

Here goes the new brain teaser!

Your new task is to get a list of running processes, assign it to a variable and output the result to the console window.

Use the minimal number of characters. Be aware, a space is a character too. The shortest solution wins.

You need to send your answers by Friday and the winner will be announced on the next Monday. This time, the prize is the eBook version of Learn Windows PowerShell 3 in a Month of Lunches, Second Edition written by Don Jones and Jeffery Hicks. We would like to thank our sponsor Manning, a publisher of high quality computer books for professionals, for providing such a valuable prize. Manning is releasing the print version of Learn Windows PowerShell 3 in a Month of Lunches, Second Edition today.

Good luck!

Share on: