title: How can I make powershell job to return the object type I want?
body: <p>I'm trying to use powershell job in order to build a TreeView object and return it, instead, I get PSObject type everytime the job ends.</p>
  
  <p>I've tried returning the TreeView object in many ways, like adding [System.Windows.Forms.TreeView] before the variable name in the return line, or as a part of an array, nothing seems to return the expected result</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$job = Start-Job -ScriptBlock{
      Add-Type -AssemblyName System.Windows.Forms
      $Tree = New-Object System.Windows.Forms.TreeView
      Return $Tree
  }
  Wait-Job $job
  $Output = Receive-Job $job
  </code></pre>
  
  <pre class="lang-bsh prettyprint-override"><code>$Output.GetType()
  
  IsPublic IsSerial Name                                     BaseType
  -------- -------- ----                                     --------
  True     True     PSObject                                 System.Object
  </code></pre>