Search pattern and grab the whole row to result

Dear expert

I need this code below to work as I wanted, now this code below grab network shares and a $pattern show name, line and write time. I want it to if you find the Pattern grab the whole row. I tried |Get-Content but it grabbed everything. I don't need to know the name and line and write time, so i can just remove $LWT = (Get-Item -Path $_.Name).LastWriteTime $_.Group | Select-Object Path, LineNumber, @{n='LastWriteTime'; e={$LWT}}

Help please. Thanks

$networksshare = "\\rvp01\logs", "\\rvp01\logs2","\\rvp02\logs","\\rvp02\logs2","\\srvp03\logs","\\srvp03\logs"
$Pattern = 'List6-75'

$results = Get-ChildItem -Path $networksshare -Recurse -File |
	Select-String -Pattern $Pattern |
	Group-Object Path |
	ForEach-Object {
		$LWT = (Get-Item -Path $_.Name).LastWriteTime
		$_.Group | Select-Object Path, LineNumber, @{n='LastWriteTime'; e={$LWT}}
	
}
$results | Out-File d:\test\result.txt

Open in new window

LVL 1
WeTiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
$networksshare = "\\rvp01\logs", "\\rvp01\logs2","\\rvp02\logs","\\rvp02\logs2","\\srvp03\logs","\\srvp03\logs"
$Pattern = 'List6-75'

Like this?
$results = Get-ChildItem -Path $networksshare -Recurse -File |
	Select-String -Pattern $Pattern |
	Group-Object Path |
	ForEach-Object {
		$_.Group | Select-Object Path, Line
	
}
$results | Out-File d:\test\result.txt

Open in new window


It's not clear if you still need to group results, or show the path, but I left those in for now.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WeTiAuthor Commented:
Hi, due to the line is too long the outfile show like this:  

Line
2018-01-19 Warning (Some text here and end with)...

It shortend the row with ...

I am looking it to get full row.
0
WeTiAuthor Commented:
Format-list did the trick
1
footechCommented:
You could also try the -Width parameter of Out-File.  Just set to something long enough for your contents.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.