Hello, I am looking for Powershell assistance with extracting text contained between known words.
I have the script below which works for letters/number, however I need to be able search for [Section1] and [Section2]. The script below doesn't work with the square brackets (assuming characters might be reserved or ignored in some way)? Can anyone help?
$flag=0
Get-Content c:\in.txt |
foreach {
Switch -Wildcard ($_){
"*SECTION1*" {$flag=1}
"*SECTION2*" {$flag=0}
}
if ($flag -eq 1){
Out-File C:\out.txt -InputObject $_ -Append
}
}