Hello @Surabhi Jaiswal !
You have two complete itereations thru the ClusterResource collection, here is an approach with one complete iteration. Does this work for you?
Get-ClusterResource |
Where-Object {
$_.ResourceType.Name -in "Generic Service","NetworkName" -and $_.OwnerGroup.Name -like 'Rhapsody*'
} | Where-Object ResourceType.Name -eq 'Networkname' | Select -ExpandProperty Name
I've tested it with this little code snippet:
$o = `
[PSCustomObject]@{Name = 'Cluster Disk 1'; State = 'Online'; OwnerGroup = 'RhapsodyHA_AP'; ResourceType = 'Physical Disk'},
[PSCustomObject]@{Name = 'Cluster IP Address'; State = 'Online'; OwnerGroup = 'Cluster Group'; ResourceType = 'IP Address'},
[PSCustomObject]@{Name = 'Cluster Name'; State = 'Online'; OwnerGroup = 'Cluster Group'; ResourceType = 'NetworkName'},
[PSCustomObject]@{Name = 'HIF Testing'; State = 'Online'; OwnerGroup = 'HIF Testing'; ResourceType = 'NetworkName'},
[PSCustomObject]@{Name = 'IP Address 192.168.2.1'; State = 'Online'; OwnerGroup = 'RhapsodyHA_AP'; ResourceType = 'IP Address'},
[PSCustomObject]@{Name = 'IP Address 192.168.2.23'; State = 'Online'; OwnerGroup = 'HIF Testing'; ResourceType = 'IP Address'},
[PSCustomObject]@{Name = 'Philips Healthcare Integration Found'; State = 'Online'; OwnerGroup = 'HIF Testing'; ResourceType = 'Generic Service'},
[PSCustomObject]@{Name = 'Rhapsody 6.6.1'; State = 'Online'; OwnerGroup = 'RhapsodyHA_AP'; ResourceType = 'Generic Service'},
[PSCustomObject]@{Name = 'RhapsodyHA_AP'; State = 'Online'; OwnerGroup = 'RhapsodyHA_AP'; ResourceType = 'NetworkName'}
$o |
Where-Object {
$_.ResourceType -in "Generic Service","NetworkName" -and $_.OwnerGroup -like 'Rhapsody*'
} | Where-Object ResourceType -eq 'Networkname' | Select -ExpandProperty Name
Best whishes
---
If this answer was helpful, accept and upvote it please.