Search files content fast in powershell
I also suggest to use a better RegEx but stay with PowerShell.

Without exactly knowing your $testnames you can manually or automatically build a RegEx with a lookbehind and alternations and read the *.cs files only once.

## build some sample files 
'foo','bar','baz'|ForEach-Object{"Resources.$_" &gt; "$_.cs"}

$testnames = [RegEx]"(?&lt;=Resources\.)(foo|bar|baz)"
# (zero length look behind assertion)(alternation)

$Result =  Get-ChildItem *.cs -Recurse -File | 
  Select-String -Pattern $testnames|
    Select-Object @{n='UsedIcons';e={$_.Matches.Groups[0].Value}} -Unique

$Result


Sample output:

UsedIcons
---------
bar
baz
foo