I have two functions one which outputs a set of directories And one needs to receive that set and do a foreach on it, however it seems the second function is only receiving one of the directories (the last one).
What am I doing wrong.
Get-Directories {
return Get-ChildItem | Where-Object { $_.PSIsContainer -eq $True }
}
function Invoke-Build {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[string[]]$directories
)
Write-Output $dir
foreach ($dir in $directories) {
Set-Location $dir
Build
Set-Location ..
}
Get-Directories | Invoke-Build
The output though is just the last directory found by Get-Directories. I need the second function to accept array input as I plan to make it do things asynchronously.
process{...}block.