Hyper-V, PowerShell: List not clustered VM's.

Before you continue please consider clicking on one of the horrible ads. I know they are a pain but they help me pay for the hosting of this site. It owes me a lot of money. Sob story over.

I recently found myself in the situation where I was asked to produce a report on how many Hyper-V Vm's existed but have not been added as roles to failover cluster manager, which seems like a pretty simple task but presented its own set of challenges.

So lets do it.

  • Get a list of VM's from each Hyper-V host, then
  • Get a list of roles from Failover cluster manager then
  • compare these 2 lists
  • Wait 100 years for all this to finish.

Anyone that has used failover cluster manager is probably aware that when you add a new VM you are presented with a list of VM's that "qualify" to be clustered services, so you would think there is a quicker way... and there is!

Lets take a closer look at a VM object.

In more detail:

Can you see it? Look closer.

Did you know that was there? I didn't.  This makes it much easier.  We can now do this with a simple one liner.

 get-vm | where{$_.IsClustered -eq $false}

This will get you VM's that arent clustered on a single host.  To expand this to a whole cluster

$ClusterNodes = Get-ClusterNode 

foreach($ClusterNode in $ClusterNodes)
        get-vm | where{$_.IsClustered -eq $false}