Get-VMsByClusterNode

Here’s a very simple but usefull function to have a view on which Virtual Machine is currently running (or not, there a State column!) on which node of a MSCS failover cluster.

Function Get-VMsByClusterNode {
Import-Module FailoverClusters
[string]$cluster=Get-Cluster
$ClusterNodes=Get-ClusterNode
ForEach ($ClusterNode in $ClusterNodes)
    {
    [string]$ClusterNode=$ClusterNode
    Get-ClusterNode $ClusterNode | Get-ClusterGroup | Where { $_ | Get-ClusterResource | Where { $_.ResourceType -like "Virtual Machine" } }
    }
}

Leave a Reply

Scroll to Top