I have a variable that stores some properties like prop1, prop2, prop3… where a few are in form of hashtables. I’d need to select a couple of the properties stored in the variable and some pieces of the hashtable. The hashtable is in form of e.g. prop2: {@{label1=value1},@{label2=value2},…}
when I try
$var | select prop1 -expandproperty prop2
I’m not getting the output I need. I only want to get value1. What would be the right way to extract the properties out of ?
$var.item(0)
Thanks Jon but in short I get PSCustomObject doesn’t contain method item.
So you don’t have a normal hashtable then.
To be able to help any further, you’ll need to post your code. You can also pipe your data to get-member and look at the information you can access.
$var is of PSCustomObject type where prop2 is System.Object. The results come from Get-HPiLOHealthSummary commandlet by HPE.
I managed to get a bit further going
$vars | select prop1, @{name=“prop2”;expression={[string]::join(“;”,($_.prop2))}}
but my prop2 now displays as
@{label=value};@{label=value}
how to get rid of @{} then?
Wow! and exact match. Excellent googling skills Jon Many thanks