In PowerShell I find myself doing this kind of thing over and over again for matches:
some-command | select-string \'^(//[^#]*)\' | %{some-other-command
You could try this:
Get-Content foo.txt | foreach { some-othercommand [regex]::match($_,'^(//[^#]*)').value }