title: How to bind event to powershell command output stream?
body: <p>Using PowerShell Object i know how to invoke cmdlets ASYNCHRONOUSLY and bind event that gets fired as and when data arrives as output.</p>
  
  <pre><code>PowerShell PowerShellInstance = PowerShell.Create();
  //Add necessary commands
  PSDataCollection&lt;PSObject&gt; outputCollection = new PSDataCollection&lt;PSObject&gt;();
  outputCollection.DataAdded += outputCollection_DataAdded;
  IAsyncResult result = PowerShellInstance.BeginInvoke&lt;PSObject, PSObject&gt;(null, outputCollection);
  
  void outputCollection_DataAdded(object sender, DataAddedEventArgs e)
  {
      //process output where sender is that outputCollection
  }
  </code></pre>
  
  <p><strong>How to do the same in Synchronous manner. [Note: I should use Runspacepool, which i can specify to PowerShellInstance's Runspacepool property]</strong></p>