I have a function call inside foreach loop, i do not want to wait till that function gets completed and need to make my foreach loop running, so i can achieve multi-threading concept in powershell. Is this possible? Please guide thanks.
foreach ($folders in $txtfilepath)
ftp_upload1 $foldertemp $Freelancername $articleid $Freelancermailfinal
As this is a upload function and wait time is more sometimes so i need to work as multi-thread so it will make all upload requests asap.
So Finally i got answer.
$FOO = {write-host "HEY"}
Start-Job -ScriptBlock $FOO | wait-job |Receive-Job
parameterize script blocks
$foo = {param($bar) write-host $bar}
Start-Job -ScriptBlock $foo -ArgumentList "HEY" | wait-job | receive-job
No doubt that i copied from some other post and here is the Link