title: Replace all the lines between two lines using powershell
body: <p>I have a Config file and I want to replace all the lines between two lines using powershell
  Here is my code:</p>
  
  <pre><code> $HttpPath = "C:\Oracle\Middleware\Oracle_Home\user_projects\domains\my_domain\config\fmwconfig\components\OHS\ohs1\httpd.conf"
   $NewLine = 'Options -Indexes'
   $Pattern = '(?&lt;=&lt;Directory /&gt;).*?(?=&lt;/Directory&gt;)'
  (Get-Content -Path $HttpPath -Raw) | ForEach-Object {
    $_ -replace $Pattern,$NewLine
   } | Set-Content -Path $HttpPath
  </code></pre>
  
  <p>Here is text of config the file:</p>
  
  <pre><code> &lt;Directory /&gt;
   AllowOverride none
   Require all denied
   &lt;/Directory&gt;
  </code></pre>
  
  <p>I want to replace two lines of "Hi" and "Hello" with one line "Options -Indexes". Result should look like:</p>
  
  <pre><code>&lt;Directory /&gt;
  Options -Indexes
  &lt;/Directory&gt;
  </code></pre>
  
  <p>This script works if the file content be like:</p>
  
  <pre><code>&lt;Directory /&gt; AllowOverride none Require all denied &lt;/Directory&gt;
  </code></pre>
  
  <p>Then Output be like:</p>
  
  <pre><code>&lt;Directory /&gt;Options -Indexes&lt;/Directory&gt;
  </code></pre>
  
  <p>But as the content of file splits in separate lines, this does not works.</p>