I'm quite new in PowerShell and I would need a little bit of support how to replace values in an array. Please have a look at my example:
[array[]]$nodes = @()
[array[]]$nodes = get-NcNode | select-object -property Node, @{Label = "slot"; expression = {@("a")*4}}
$nodes
Node slot
---- ----
nn01 {a,a,a,a}
nn02 {a,a,a,a}
nn03 {a,a,a,a}
nn04 {a,a,a,a}
$nodes[0].slot[0]
a
$nodes[0].slot[0] = "b" #I try to replace a with b
$nodes[0].slot[0]
a #It didn’t work
$nodes[0].slot.SetValue("b",0) #I try to replace a with b
$nodes[0].slot[0]
a #It didn’t work
$nodes[0] | Add-Member -MemberType NoteProperty -Name slot[0] -Value "b" -Force
$nodes[0]
Node slot slot[0]
---- ---- -------
nn01 {a,a,a,a} b #That’s not what I wanted
$nodes[0].slot[0] = "b"works fine for me. Note that the$nodesarray is not inline with yourSelect-Objectexpression. If the slot is an array, there should be spaces between the strings in the display output:{a, a, a, a}. I recommend you to use this$Nodes = 1..4 | Select-Object @{n = 'Node'; e = { "nn0$_" }}, @{n = 'Slot'; e = { @('a') * 4 }}for the minimal reproducible example input.[array[]]$nodes = @(), is pointless: its effects are replaced by the next[array[]]$nodes = ...statement.[array[]]is changed to[array].