Substring is getting too less data
<p>I want to grab lots of text content from a .sql file between a <code>--Start</code> and <code>--End</code> comment.</p>

<p>Whatever I do somehow I don`t get the substring method correctly to grab only the text within the --Start and --End comment:</p>

<p><strong>text.sql</strong></p>

<pre><code>This text I want not
--Start
this text I want here
--End
This text I want not
</code></pre>

<p>This is what I tried:</p>

<pre><code>$insertStartComment = "--Start"
$insertEndComment = "--End"

$content = [IO.File]::ReadAllText("C:\temp\test.sql")
$insertStartPosition =  $content.IndexOf($insertStartComment) + $insertStartComment.Length

$insertEndPosition =    $content.IndexOf($insertEndComment)
$content1 = $content.Substring($insertStartPosition, $content1.Length - $insertEndPosition)
$content = $content1.Substring(0,$content1.Length - $insertEndPosition)
</code></pre>

<p>It would be nice if someone could help me out find my error :-)</p>