extracting value from an array

I’m not sure what I’m doing wrong here, usually I’m ok with this type of thing but I’m going around in circles a bit with this.

I’ve working on a script to check Clustered Resources are on the Node we want them to be, no preferred Owners. Ive got an array holding the preferred state. Then I query the Cluster for current state. If there is a mismatch, I want to fail the Resource over to the Preferred Node.

The script I’m using is below, the problem I’m having is expanding this @{OwnerNode=VORSQL-T01} to get the OwnerNode value. I’ve tried all the usual ways that I’m familiar with but none seem to be working.

I’m doing something wrong, but can’t see what…

Script :

$Cluster = @(
[PSCustomObject]@{ClusterName = "VORCS-T01" ; OwnerGroup = "SQL Server (TEST98)"; OwnerNode = "VORSQL-T01"; }
[PSCustomObject]@{ClusterName = "VORCS-T01" ; OwnerGroup = "SQL Server (TEST99)"; OwnerNode = "VORSQL-T02"; }
)

$CurrentSituation = Get-ClusterResource | ?{$_.ResourceType.name -eq "Sql Server"} | Select @{L="Clustername"; E={$_.Cluster.Name}}, OwnerGroup, OwnerNode

$CurrentSituation | % {
$_ | % {
$Item = $_
if(!( $Cluster | ?{$_.ClusterName -eq $Item.ClusterName -And $_.OwnerGroup -Eq $Item.OwnerGroup -And $_.OwnerNode -Eq $Item.OwnerNode } )) {
"$($Item.OwnerGroup) is not on preferred Node of $($Cluster | ?{$_.OwnerGroup -Eq $Item.OwnerGroup -And $_.OwnerNode -Ne $Item.OwnerNode } | Select OwnerNode) "
}
}
}

Output:

SQL Server (TEST98) is not on preferred Node of @{OwnerNode=VORSQL-T01}

Select-Object -ExpandProperty OwnerNode

Thank you very much!

I’m kicking myself as I know that command and use it elsewhere…