결과를 기다리지 않고 C#에서 PowerShell 스크립트를 실행하려고합니다.결과를 기다리지 않고 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();
그러나 스크립트가 완료 될 때까지 기다립니다.