Let's say I have the results of a call to Select-String in a variable $mat, parsing a regular expression from file contents:
$mat = cat errors.txt | Select-String "'(?<code>\w+)'.+ID (?<id>[^:]+)"
According to the output of $mat | Get-Member the result contains a Matches property of type Match[].
When I execute the following I get all the matches of my regular expression output:
PS > $mat | Select-Object -Property Matches
Matches
-------
{'ACCFWD', ID 16}
{'EQASIAN', ID 448}
Why doesn't this next block of code using foreach to select the Matches have the same output:
PS > $mat | ForEach { $_.Matches }
Groups : {'ACCFWD', ID 16, ACCFWD, 16}
Success : True
Captures : {'ACCFWD', ID 16}
Index : 20
Length : 15
Value : 'ACCFWD', ID 16
Groups : {'EQASIAN', ID 448, EQASIAN, 448}
Success : True
Captures : {'EQASIAN', ID 448}
Index : 20
Length : 17
Value : 'EQASIAN', ID 448