I was unable to create a Powershell function that takes more than one scriptblock parameter. Here's a simplified test script. What is the problem with multiple scenarios?
function Task1 { param([scriptblock]$f={}) $f.Invoke() } function Task2 { param([scriptblock]$f={}, [scriptblock]$k={}) $f.Invoke() $k.Invoke() } Task1({write-host "hello" -nonewline }) Task1({write-host " world" }) Task2({write-host "hello" -nonewline }, { write-host " world" })
This leads to the following conclusion:
hello world Task3 : Cannot process argument transformation on parameter 'f'. Cannot convert the "System.Object[]" value of type "S ystem.Object[]" to type "System.Management.Automation.ScriptBlock".
source share