Creating an array similar to the output of a cmdlet

by Oct 7, 2011

Hey,

how can I create an array that is formated like the output of an cmdlet?

For example:

$a = Get-Process -Name "a*"

$a is now an object of the type 'array'. I have the ability to access each element of the array with an identifier like $a[0]. Every element contains several information about the process, like the ID or the ProcessName. It's also possible to use $[0].ID just to get the ID of the process stored in element '0'.

Is it possible to manually create an array in this format?

In the beginning i was hoping it wourld work this, but in the end it's not nearly the same or comfortable:

$b = @()
$b += "Name = Example"
$b += "ID = 0"
$b += "Name = Example2"
$b += "ID = 1"

I hope i could make this problem clear. Thanks in Advance!

– Kuro