I'm running the following script to check a group of files for card numbers. When I run it against a group of 38 files that are a total of 600mb, it consumes max cpu (50% restricted) and max memory (3.3GB of 4.0GB physical).
Looking for ideas on why this may be and how to optimize this.
Thanks!
Get-ChildItem "c:\REGEX\ScanMeFiles\" -Recurse |`
Foreach-Object{
$content = Get-Content $_.FullName
$outfile = 'c:\regex\results\'+$_.BaseName+'_results.log'
$content | Where-Object {$_ -match '\b(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}\b'} | Set-Content $outfile
}