title: Nesting foreach state
body: <p>I have the following script to list the running vms on hyper-V servers:</p>
  <pre><code>$VirtualHosts = Get-content &quot;C:\scripts\Hosts.txt&quot;
  ForEach ($Guest in $VirtualHosts)
  {Get-VM -ComputerName $Guest | Where State -eq Running | FT Name}
  </code></pre>
  <p>I want to add the functionality of rebooting the computers using the <code>Restart-Computer</code> cmdlet.  To do this, I plan on using a nested foreach statement.  Can you help me with the nested statement?</p>