I pieced together a pipeline that returns a list of files and their paths if said files match prescribed patterns:
Param ($dropDir)
$MatchingScripts = Get-ChildItem $dropDir\*.sql -Recurse
| Select-String -pattern \*ONEFISH\*,\*TWOFISH\*,\*REDFISH\*
| group path
| Foreach-Object {$_.Name}
| Out-File D:\logging\scrubfiles.log
return $MatchingScripts
So there's one param in there where I feed in the dynamically-named drop path every time and search down that path. The goal then is to return $MatchingScripts array to the build template and throw the array into a ForEach<string> loop that will InvokeProcess on a custom tool which will scrub each \path\file\ and replace said token value patterns.
Problem: I can't get that array from PowerShell fed back to the team build. I've tried containing the script in a .ps1 along with a closing return $MatchingScripts ...but nothing is reaching the pre-defined IEnumerable<String> by the same name 'MatchingScripts' in the build template.
I'm still trying to make the TFSBuildExtensions InvokePowerShellCommand activity to do this for me, as well, but the problem there is a conversion of types that have to be overcome (PSOBject to Array of Strings).
They key bit is that tool I have to send this array through needs to consist of strings.