You could try something like this:
$text = @"
First: John
Last: Doe
lasld
First: Mary
dasd
Last: Smith
"@
$text | Select-String '(?s)First:\s+(\w+).*?Last:\s+(\w+)' -AllMatches |
ForEach-Object { $_.Matches } |
ForEach-Object { "$($_.Groups[1].Value) $($_.Groups[2].Value)" }
Output:
John Doe
Mary Smith
It requires the input as a single multi-line string, so you would need to use $text = Get-Content "c:\dev\test\data.txt" -Raw or $text = (Get-Content "c:\dev\test\data.txt") -join [environment]::NewLine
Regex101: https://regex101.com/r/bD2oU3/1
Update: I realized that some people may have middlenames, so as long as the line ends with the name like the samples, you could use the regex below to include more than the first word after "First:" and "Last:". It also removes trailing whitespace on the line
$text = @"
First: John Lala
Last: Doe
lasld
First: Mary
dasd
Last: Smith Test
"@
$text | Select-String '(?ms)First:\s+(.*?)\s{0,}$.*?Last:\s+(.*?)\s{0,}$' -AllMatches |
ForEach-Object { $_.Matches } |
ForEach-Object { "$($_.Groups[1].Value) $($_.Groups[2].Value)" }
John Lala Doe
Mary Smith Test
Select-String "First:","Last:"gives you the output, that you describe, as the strings in your output neither contain "First:" nor "Last:".