I am trying to create a new custom object with data input from another object.
$clusters = Get-EMRClusters
$runningclusters = $clusters | Where-Object {
$_.Status.State -eq "Running" -or
$_.Status.State -eq "Waiting"
}
$runningclusters
looks like
id name status -- ---- ------ j-12345 cluster1 running j-4567 cluster2 running
I want to create a new PSobject $o
with a 4th column named PendingShutdown
that's a boolean.
id name status pendingshutdown -- ---- ------ --------------- j-12345 cluster1 running False j-4567 cluster2 running False
I have tried running this:
$o = New-Object PSObject
$o | Add-Member -NotePropertyName id -NotePropertyValue $runningclusters.id
$o | Add-Member -NotePropertyName name -NotePropertyValue $runningclusters.name
$o | Add-Member -NotePropertyName status -NotePropertyValue $runningclusters.status.state
$o | Add-Member -NotePropertyName PendingShutdown -NotePropertyValue $true
But my output for $o
for the columns id
and name
are just objects themselves, not rows of IDs. How do I make an object to look like my desired object above?