I was following the example given in post
to call a simple function in parallel. I am getting the error but unable to figure out why.
Below is the code block.
function run-thescript
{
param (
$Parameter1,
$Parameter2
)
#Write-Host 'inside the outer function'
Write-Output "the first parameter is $Parameter1 and second is $Parameter2"
}
$cmd = {
param($a, $b)
Write-Host $a $b
run-thescript -Parameter1 $a -Parameter2 $b
}
Start-Job -ScriptBlock $cmd -ArgumentList @('input1','input2')
Error thrown after running
Get-Job | % { Receive-Job $_.Id; Remove-Job $_.Id }
is
The term 'run-thescript' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (run-thescript:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost