1
votes

I need to call a ps1 Script during going through another ps1 file. The new call shouldn't interrupt the script which I'm going through. Also I always call the Powershell scripts like this: powershell -ExecutionPolicy Bypass -File file.ps1 -param log_14.txt due to execution policies.

I tried following code in my .ps1 script, sadly it doesn't work:

    Start-Job PowerShell -Argument "sort.ps1 -file $fileName"

Any ideas how to make it work?

1
So it means you need to pass a parameter to a ps1 script within a job? - programmer365
@WasifHasan yes i need to call a FIle with a Parameter in my File which I'm gooing through - fbe106360

1 Answers

0
votes

Try this:

$job = Start-Job -ScriptBlock {
  powershell -ExecutionPolicy Bypass -File "filepath.ps1 Param"
}
$job | wait-job | receive-job