Menu Close

How to get all Cluster Virtual Servers and their possible Nodes from SCOM

image

I have had to use this a few times for customers so I thought I might publish it.  Comes in handy when managing alerts from cluster objects and associating them with a physical node, or when extending computer properties.

 

# Get Virtual Servers Array $VirtualServers = Get-SCOMClass -name 'Microsoft.Windows.Cluster.VirtualServer' | Get-SCOMClassInstance | Sort #Get the relationship $rid = Get-SCOMRelationship -DisplayName 'Health Service manages Entity' #Set Array to empty [array]$VirtualClusterItems = @() FOREACH ($VirtualServer in $VirtualServers) { [string]$VirtualServerName = $VirtualServer.DisplayName #Create a PowerShell Object to assign properties $VirtualClusterItem = New-Object PSObject $VirtualClusterItem | Add-Member -type NoteProperty -Name 'VirtualServer' -Value $VirtualServerName #Get the nodes in an array which have a health service relationship managing the cluster name $Nodes = Get-SCOMRelationshipInstance -TargetInstance $VirtualServer | Where-Object {$_.relationshipid -eq $rid.id} | Select-Object -Property SourceObject $NodeNames = $Nodes.SourceObject.DisplayName | Sort-Object FOREACH ($NodeName in $NodeNames) { IF (!($VirtualClusterItem.Node1)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node1' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node2)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node2' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node3)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node3' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node4)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node4' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node5)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node5' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node6)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node6' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node7)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node7' -Value $NodeName } ELSEIF (!($VirtualClusterItem.Node8)) { $VirtualClusterItem | Add-Member -type NoteProperty -Name 'Node8' -Value $NodeName } } $VirtualClusterItems += $VirtualClusterItem } #Output $VirtualClusterItems | Out-GridView

10 Comments

      • Tiago

        There are two clusters that I have that are 2016 that does not appear on the list when running the script.

        They also do not show when I run only the command:
        Get-SCOMClass -name ‘Microsoft.Windows.Cluster.VirtualServer’ | Get-SCOMClassInstance | Sort

        But they are listed in scom: Microsoft windows cluster -> Cluster -> Cluster State

    • Kevin Holman

      Active Node is a bit of a misnomer, because clusters have the cluster resource, individual resources, and resource groups, each could be hosted by a particular node. But SCOM does not collect this information by default. Years ago I leveraged and updated a management pack that would monitor cluster resource groups, and alert when they were not running on their set “preferred node”.

  1. Martin

    is there also a way to show greater than two node clusters? we have some of them with 4 or 6 nodes.
    Would be great to have here somthing!

    From script there should be shown more – but they always two…and on the more node clusters…always the same two servers are shown!

    • Kevin Holman

      I assumed this would work up to 8 nodes as I designed it. It must be something in the script, I’d recommend you step through it…. and see where it is not pulling back all your nodenames.

Leave a Reply

Your email address will not be published. Required fields are marked *