title: Powershell getting lines from a text file after the last occurrence of a string
body: <p>I have a robocopy log file that I am working with, and I need to extract the summary lines using powershell.  The issue that I am running into is that the summary is not always the same length in number of lines.  </p>
  
  <p>Assuming the log file looks like this:</p>
  
  <pre><code>-------------------------------------------------------------------------------
     ROBOCOPY     ::     Robust File Copy for Windows                              
  -------------------------------------------------------------------------------
  
    Started : Tue Dec 01 06:55:11 2015
  
     Source : C:\Source Path
       Dest : E:\Destination Path
  
      Files : *.*
  
    Options : *.* /TEE /S /E /COPY:DAT /PURGE /MIR /NP /R:2 /W:2 
  
  ------------------------------------------------------------------------------
  List of files here
  List of files here
  List of files here
  ------------------------------------------------------------------------------
                  Total    Copied   Skipped  Mismatch    FAILED    Extras
       Dirs :       945         0       945         0         0         0
      Files :     10118         4     10114         0         0         3
      Bytes :   1.245 g   323.9 k   1.244 g         0         0         0
      Times :   0:00:17   0:00:00                       0:00:00   0:00:17
  
      Speed :             5264920 Bytes/sec.
      Speed :             301.261 MegaBytes/min.
  
      Ended : Tue Dec 01 06:55:28 2015
  </code></pre>
  
  <p>I can statically get the last 11 lines of the file with the command <code>$summary = Get-Content $log | Select-Object -last 11 | Out-String</code>, but the two speed lines are only listed if data has actually moved, which otherwise results in the last of lines of the file list.  Ultimately not a huge problem, but it doesn't look very pretty.</p>
  
  <p>Instead of a set number of lines, how can I get the last lines from the file, after the last (or 4th, there are always 4) occurrence of the delimiter <code>---------------</code>? </p>