$lines = "error: disk", "info: ok", "error: net" # two error lines $lines | Select-String -Pattern '^error' | ForEach-Object { $_.Line }
match lines and read the matched value