I'm trying to parse a file that contains blocks of text in this format(there can be 1-n of these):
-----------------------------------------------------------
KB Article Number(s): 2028769, 2072493, 2120979, 2143880, 2163958, 2163980, 980653, 980883, 981155, 981867, 982321, 982850
Language: All (Global)
Platform: x64
Location: (http://foo.bar.com)
Password: foo
-----------------------------------------------------------
The text is coming from an MS Hotfix request email if anyone is interested.
I have the following powershell one liner:
$file | select-string "(?<Name>\w+):(?<Value>.*)" -allmatches | SELECT @{N="Name";E={$_.Matches[0].Groups[1].Value}}, @{N="Value";E={$_.Matches[0].Groups[2].Value}}
This give me a flat set of name value pairs, I would like it to return an array of hashtables with each of the 5 Keys populated.
I'm not sure if the problem is my regex or how I'm accessing the matches (There must be a less verbose way of picking these out).