title: PowerShell via C# Console Output different
body: <p>Fairly new to C#, not so new to PowerShell. </p>
  
  <p>I want to use C# to execute PowerShell code. However the output of objects isn't in the same as running commands in a PowerShell window. I get back the object's name rather than its data. Here's what I'm trying:</p>
  
  <pre><code>string script = @"
      get-process | ft
  ";
  
  PowerShell powerShell = PowerShell.Create();
  
  powerShell.AddScript(script);
  var results = powerShell.Invoke();
  foreach (var item in results)
  {
      Console.WriteLine(item);
  }
  </code></pre>
  
  <p>Returns: </p>
  
  <blockquote>
    <p>Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData</p>
  </blockquote>
  
  <p>However in a PowerShell command line window it returns a more formated table view:</p>
  
  <blockquote>
    <p>PS C:\Dropbox\PowerShell> ps | ft</p>
    
    <p>Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id  SI
    ProcessName
    -------  ------    -----      ----- -----   ------     --  -- -----------
        131      12     1980       2572    85     0.45  13216   1 acrotray</p>
  </blockquote>
  
  <p>Really would like two things:</p>
  
  <ol>
  <li>code that will produce the same output as the PowerShell command window</li>
  <li>an explanation of what is going on so I can learn how to navigate it better</li>
  </ol>
  
  <p>Thanks in advance! </p>