I have the following log entry that I am processing in PowerShell I\'m trying to extract all the activity names and durations using the -match
operator but I am onl
The -match operator is meant to be used just once; it doesn't do a global match on the input. Keith Hill put a suggestion for a -matchall operator on Microsoft connect here.
I'll suggest another way to do it. If the log entry is in a file, you can use the switch statement to accomplish the same thing:
switch -regex -file .\log.txt { $entryRegex { $matches[1] + ", " + $matches[2] } }
This is the output I get with this statement if $entryRegex
has the regular expression you defined:
Get Client Model, 0
Parse Expression, 0
Get Abstract Query, 0
Compile Query, 0
Execute Query, 63695
Get Query Plan Complexity, 0
Total, 63696
Async Total, 63696