I'm suspect I am going about this the wrong way and need to switch to a hash table but is it possible to update a specific value in an Array? The script retrieves the cluster nodes and stores the data in a array, then proceeds to reboot each one, once rebooted I want to update the reboot 'column' value in the array to 1.
$Array=@()
$Cluster = Get-ClusterNode
foreach ($Node in $Cluster)
{
$item = New-Object PSObject
$item | Add-Member -type NoteProperty -Name 'Node' -Value $Node.Name
$item | Add-Member -type NoteProperty -Name 'State' -Value $Node.State
$item | Add-Member -type NoteProperty -Name 'Rebooted' -Value "0"
$Array += $item
}
foreach ($row in $Array | Where { $Array.Rebooted -eq "0" })
{
Reboot-Function -Node $row.Node
$Array.Rebooted += 1 | Where-Object {$Array.Node -eq $row.Node}
}
$Array
$row. Simply do$row.Rebooted = 1instead of$Array.Rebooted += 1 | Where-Object {$Array.Node -eq $row.Node}Where { $Array.Rebooted -eq "0" }doesn't seem to be needed at all, since-Name 'Rebooted' -Value "0".