I have some dificulties with using an User Define Function inside the ForEach-Object when the Parallel is active:
function Add([Int]$number) {
Write-Output "Run for $number"
}
1..4 | ForEach-Object -Parallel {
Add -number $_
}
I get an error message:
The term 'Add' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I believe it is a common proactivity use an UDF inside foreach loop. Do you have any workaround for that? The $using: is applicable only for variable, not function, right?