title: How to remove First and Last Line in Powershell
body: <p>This script will do some processing on csv file notably removing first line (subsequent to <a href="https://stackoverflow.com/questions/31732889/how-to-export-to-non-standard-csv-with-powershell">How to export to &quot;non-standard&quot; CSV with Powershell</a> ) :</p>
  
  <pre><code>Import-Csv in.csv -header Date,Time,O,H,L,C,V|select * -ExcludeProperty time|
  %{$_.date = [datetime]::ParseExact($_.date,"yyyy.MM.dd",$null).tostring("yyMMdd");$_.v=1;$_}|
  ConvertTo-Csv -NoTypeInformation|
  select -skip 1|
  %{$_ -replace '"'}|
  Set-Content out.csv -encoding ascii
  </code></pre>
  
  <p>Now I need to refine it by also removing last line. I tried to add :</p>
  
  <blockquote>
    <p>select -skip ($_.Count - 1) </p>
  </blockquote>
  
  <p>but it generates exception.</p>
  
  <p>So what the right syntax ?</p>