I am a novice and have been tasked to extract data from a bunch of text files. I have managed to put together some very simple PowerShell code (seen below) that does most of the work. However, the Line object is truncated in the output file and I was wondering if there was a way I could modify the code to (by using Select-Object -ExpandProperty Line?
) but not sure how to incorporate it with the rest of the script. Here is the code...
Select-String -Path "C:\Users\*.txt" -Pattern "reduce", "increase", "cease", "stop" -Context 2 | Select-Object Filename, Pattern, LineNumber, Line| Out-File "C:\Users\Recommendations_inital.txt"
Any assistance is very much appreciated!