title: Powershell - how to obtain previous lines from text file?
body: <p>I have a text file containing hundreds of lines of text containing database info.</p>
  
  <p>I'm trying to extract the <code>DatabaseId</code>s for any database which is 35GB.</p>
  
  <p>I would like to interrogate the file using Powershell and produce a text file containing all the matching databases.</p>
  
  <p>So in essence, I would like to scan through the file, find a <code>DatabaseSize</code> which is 35 and then extract the corresponding <code>DatabaseId</code> from 3 lines previous.</p>
  
  <p>I've looked all over the net but can't seem to find anything which can do this.</p>
  
  <p>Example extract of text file:</p>
  
  <pre><code>ServerId = VMlinux-b71655e1
  DatabaseId = db-ecb2e784
  Status = completed
  LocationId = 344067960796
  DatabaseSize = 30
  
  ServerId = VMlinux-0db8d45b
  DatabaseId = db-cea2f7a6
  Status = completed
  LocationId = 344067960796
  DatabaseSize = 35
  
  ServerId = VMlinux-c5388693
  DatabaseId = db-9a421bf2
  Status = completed
  LocationId = 344067960796
  DatabaseSize = 8
  
  etc
  </code></pre>