Folks.
I'm trying to get a signature from the script. But each multiline match in PowerShell, which I'm doing not catching it.
The idea to catch lines of ===== and everything between them.
$Content = @'
Function Show-Example
{
#Some text
Another text
Even more text with : like that.
==============================
Org: Home Garage Inc.
Author: Mr.Smit
Created: 12/12/2021
Last update: 12/12/2021
Version: 1.1.1
==============================
Other text
And More text { Some blocks of code }
Even more not interesting text :-)
}
'@
$FilePath = "$env:USERPROFILE\Desktop"
Set-Content -Value $Content -Path "$FilePath\Example_File.ps1"
$Content = Get-Content -Path "$FilePath\Example_File.ps1"
$Signature = $Content | Select-String -Pattern '(?smi)(====.+====(\n.+){1,}){1,}'
$Signature
What I'm doing wrong?
Get-Content -Path "$FilePath\Example_File.ps1" -Raw. And then the regex should be(?ms)^\s*===+\s*(.*?)\r?\n\s*====