Relative Content

Tag Archive for c#powershellstart-job

Start-ThreadJob not executing in ps1 file when executed in System.Management.Automation.PowerShell Class

I have a powershell script that i am executing via System.Management.Automation.Powershell.Invoke. in the script i have Start-ThreadJob... | Wait-Job
Running the script on the command line using pwsh.exe does exactly what i need it it do… the job starts and the Wait-Job causes the script to pause execution until the job is done before it moves on.
When I execute this same ps1 file using System.Management.Automation.Powershell.Invoke method, the Start-Thread Job command does not seem to be getting fired. The script just continues on and this is causing the rest of my script do not do anything else as it relies on the job I intend to start.