On Tue, Apr 16, 2013 at 12:00 PM, Ben Scott <[email protected]> wrote:
> I'm having trouble figuring out how to get the regexp capture out of
> the $match object returned by Select-String though.
Ah, okay, this seems to work:
$match = & CTXCliOS.exe | Select-String -Pattern 'ClientOS\s+(.+)'
if($match) {
$clientOS = $match.Matches[0].Groups[1].Value
Set-ItemProperty -Path 'HKCU:\Software\Custom' -Name ClientOS
-Value $clientOS
}
You'll want to test that. :) In particular, I expect it will fail
miserably if the "Custom" subkey doesn't exist yet.
For reasons I don't understand, $match.Matches[0].Groups[0] appears
to be a reference to itself.
-- Ben
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin