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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top