Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Select-String output help

$
0
0

Hi

I need to get some information from a .txt file and out put that to a .CSV file.

So here is an example of what I use to do this

$GetInfo = gc "c:\temp\MyResults.txt" | Select-String -Pattern "something=" | select-object -index 0

$output = New-Object psobject
$output | Add-Member NoteProperty -Name Results -value $GetInfo
$results = $GetInfo
$results | Export-Csv c:\temp\MyResults.csv

The .txt file has more than one instance of the -Pattern but I only want the first one hence -index 0.

What I would like help with is to exclude the -Pattern itself in the returned results.

Example

-Pattern "something="

returns with the above script

something=123

but I just want

"123"


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>