title: PowerShell: How to return all the VMs in a Hyper-V Cluster
body: <p>I'm a first time programmer with PowerShell.  Running on Windows Server 2012.</p>
  
  <p>I'm trying to get a list of all VM's on my failover cluster and am working with this:</p>
  
  <pre><code>$clusterNodes = Get-ClusterNode | select Name 
  ForEach($item in $clusterNodes)
  {Get-VM -ComputerName $item}
  </code></pre>
  
  <p>And this returns a bunch of errors</p>
  
  <p>However, this works perfectly fine</p>
  
  <pre><code>$hosts = "server1", "server2", "server3", "server4"
  ForEach($item in $hosts)
  {Get-VM -ComputerName $item}
  </code></pre>
  
  <p>Is it failing because Get-ClusterNode | select Name returns the following?</p>
  
  <pre><code>Name
  ----
  server1
  server2
  server3
  server4
  </code></pre>
  
  <p>with a heading and underline?</p>