title: LinqPad (LpRun) Command Script To Create CSV file
body: <p>I've got a basic linq query that I want to put to a CSV file.  The following code works fine when run from LinqPad:</p>
  
  <pre><code>var phxTix = Companies
  .Select (c =&gt; new { 
      Ticker = c.Ticker.Trim(),
      FameTick = c.Coverage_Status.Trim()});
  
  Util.WriteCsv(phxTix, @"c:\Temp\phxticks.csv");
  </code></pre>
  
  <p>But I get an error when I run the following Powershell script from the command line:</p>
  
  <pre><code>$srcLoc = "c:\linqscripts\GetPhxTix.linq"
  $destLoc = "c:\Temp\phxticks.csv"
  lprun -lang=e -cxname=myDB -format=csv $srcLoc &gt; $destLoc
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>lprun : c:\Users\AppData\Local\Temp\LINQPad\_ibakcumi\query_bggevp.cs(35,36) : error CS1513: } 
  expected
  At c:\PS\GetPhxTicksJob.ps1:4 char:1
  + lprun -lang=e -cxname=myDB $srcLoc &gt; $destLoc
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (c:\Users\...513: } expected:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
  
  c:\linqscripts\GetPhxTix.linq(31,3) : error CS1519: Invalid token ')' in class, struct, or 
  interface member declaration
  c:\linqscripts\GetPhxTix.linq(33,1) : error CS1022: Type or namespace definition, or end-of-file expected
  </code></pre>
  
  <p>What am I doing wrong?  Or what am I missing to execute this cli script?</p>