title: Usage of powerShell.AddCommand
body: <p>I would like to execute this event using c#.</p>
  
  <blockquote>
    <p>Get-WinEvent -Path 'D:\Events\myevents.evt' -Oldest | Select-Object
    -Property * | ForEach-Object {$_ | ConvertTo-Json}</p>
  </blockquote>
  
  <p>I have written upto</p>
  
  <pre><code> path = "D:\\Events\\myevents.evt";  
   var powerShell = PowerShell.Create();
   powerShell.AddCommand("Get-WinEvent");
   powerShell.AddParameter("Path");
   powerShell.AddArgument(path);
   powerShell.AddParameter("Oldest");
   powerShell.AddCommand("Select-Object");
   powerShell.AddParameter("Property");
   powerShell.AddArgument("*");
  </code></pre>
  
  <p>I am stuck on writing for ForEach-Object {$_ | ConvertTo-Json}. Let me know how to proceed.</p>
  
  <p>Appreciate help.</p>