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!

About the author: Aleksandar Nikolic

Aleksandar is a PowerShell MVP and a co-founder of PowerShell Magazine. He is a frequent speaker at the conferences and participates regularly in IT Pro user groups worldwide. Recently, Aleksandar co-authored the highly respected Administrator’s Guide to Windows PowerShell Remoting. Follow him on Twitter at @alexandair

Related Posts

%d bloggers like this: