Grab all VMs in Hyper-V cluster Windows 2012 R2 and their disks sizes
<p>I'm trying to get html report with provisined disks size for all VMs in cluster. I'm trying to list all VMs inside cluster with:</p>

<pre><code>$VMs = get-ClusterGroup | ? {$_.GroupType -eq "VirtualMachine" } | Get-VM
</code></pre>

<p>And this works like a charm. However when I'm trying make a loop:</p>

<pre><code>foreach ($VM in $VMs)
{
 Get-VM -VMName $VM.Name | Select-Object VMId | Get-VHD
}
</code></pre>

<p>I'm getting error for each VM that is not located on my current cluster node when I'm running this.
So per each node I'm running following command:</p>

<pre><code>Get-VM -VMName * | Select-Object VMId | Get-VHD | ConvertTo-HTML -Proprerty path,computername,vhdtype,@{label='Size(GB)');expression={$_.filesize/1gb -as [int]}} &gt; report.html
</code></pre>

<p>And this works like a charm also. But this is require to login to each Hyper-V host in cluster.
How to make it happened to get output in HTML with all VMs in cluster from one node?</p>