[Solved] Powershell Script to parse selected information from txt file and output to csv

As suggested choose a regular expression that matches your requrements (see regex101.com) iterate the matches and compare the ,matched text generate a [PSCustomObject] for your csv ## Q:\Test\2018\10\17\SO_52857274.ps1 $RE = [RegEx]’^.*?\.(\d{4}):[^”]+”\s*(included with your TV purchase|.*)”$’ $CSV = Select-String ‘.\my.txt’ -Pattern $RE | ForEach-Object { IF ($_.Matches.Groups[2].Value -eq ‘included with your TV purchase’){ $Install = $True … Read more