Find string using pattern and return only the matched string


hi all

scratching head 1 , use help.

have file contains sddl dump.  trying find each sid in file , write value variable.  following regular expression seems provide pattern match.

"s-(.)*\)"

when run following commend returns whole file contents

select-string -path $file -pattern "s-(.)*\)"

want return strings matching pattern , not entire file contents.  understand output select-string matchinfo object, can't see properties or methods me extract string matching pattern.

thoughts?

tony

i've reached [regex]::matches when i've had this.  not easy 1 like...

get-content -path data.txt | %{ [regex]::matches($_, "s-[0-9\-]*") } | %{ $_.value }




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Round Robin is killing performance on our network

WMI Repository 4GB limit - Win 2003 Ent Question

Change home folder default permission?