title: PowerShell - Return the list of Hyper-V virtual machines (before a pause)
body: <p>it's been a few days since I started a PowerShell script project allowing the management of Hyper-V virtual machines via PowerShell.</p>
  <p>Unfortunately, I was confronted with a problem, and despite my little experience with PowerShell (about 1 year) I do not understand where this &quot;bug&quot; (?) comes from.</p>
  <p>More precisely, I know where the bug comes from but I do not understand it.</p>
  <p><em>Whether it is in a function.</em></p>
  <pre><code>function Get_VMs
  {
  Get-VM|Select-Object -Property Name,State
  pause
  }
  Get_VMs
  </code></pre>
  <p><em>Or out of a function.</em></p>
  <pre><code>Get-VM;pause
  </code></pre>
  <p>Or</p>
  <pre><code>Get-VM
  pause
  </code></pre>
  <p><strong>In short, the problem is this, the pause is displayed BEFORE the VMs are displayed.</strong></p>
  <p><a href="https://i.stack.imgur.com/pE74l.png" rel="nofollow noreferrer">As you can see, the pause runs before Get-VM, at least the output of Get-VM arrives after the pause.</a></p>
  <p>The problem remains the same with a Read-Host.</p>
  <p><strong>For some, the problem may seem obvious, but whatever happens, I thank you in advance for your answer.</strong></p>
  <p><em>I wish you all an excellent day or evening.</em></p>