Reputation: 773
I'm so new at powerscript I don't even know the right question to ask, so I can't even search for what I imagine is a common question.
I have:
$temp=$_|Select-String 'Game started at: (.*?)\n'
$timestamp=$temp.matches[0].groups[1].value
I tried:
$timestamp=$_|Select-String 'Game started at: (.*?)\n'.matches[0].groups[1].value
and
$timestamp=$_|Select-String 'Game started at: (.*?)\n'|echo $_.matches[0].groups[1].value
which didn't work.
How do I properly combine the two lines into one?
Upvotes: 0
Views: 162
Reputation: 54821
I don't know what your piped object($_
) was originally, but try this:
$timestamp = $_| Select-String 'Game started at: (.*?)\n' | % { $_.Matches[0].groups[1].value }
Select-String
pipes an array as results, so you need to use a foreach-loop(% is short alias) to loop through each string even if it's just one, and get the value you want.
Upvotes: 1