Question

Suppose I have the following setup:

$arr = @()
for($i=0;$i -lt 100; $i++) {
  $obj = New-Object myType
  $obj.intMember = $i
  $arr += $obj
}

And I want to turn this into an array of integers. My approach would be:

$intArr = Select-Object intMember

But this doesn't seem to be doing what I want. How do I get an actual integer array from this?

Was it helpful?

Solution

I found the answer.

$intArr = Select-Object -ExpandProperty intMember
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top