Я пытаюсь выполнить сценарий PowerShell из C#, не дожидаясь результата.Выполнение сценария PowerShell без ожидания результата
string cmdArg = "MyScript.ps1";
//Create New Runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.ApartmentState = System.Threading.ApartmentState.STA;
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
runspace.Open();
//Adds the command
pipeline.Commands.AddScript(cmdArg);
pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
//Do not wait for a result
pipeline.InvokeAsync();
runspace.Close();
Но он ждет, пока сценарий не закончится!