Beispiel #1
0
 private async void ExportInCsvAsync(Collection <PSObject> psobjs)
 {
     await Task.Run(() =>
     {
         using (Runspace runspace = RunspaceFactory.CreateRunspace())
         {
             runspace.Open();
             Pipeline pipeline = runspace.CreatePipeline();
             pipeline.Commands.AddScript(PSScriptStorage.GetCommand(null));
             pipeline.Commands.Add(PSScriptStorage.GetCommand("Export"));
             pipeline.Invoke();
         }
     });
 }
Beispiel #2
0
 private async Task <Collection <PSObject> > CallPowerShellAsync()
 {
     return(await Task.Run(() =>
     {
         using (Runspace runspace = RunspaceFactory.CreateRunspace())
         {
             runspace.Open();
             Pipeline pipeline = runspace.CreatePipeline();
             pipeline.Commands.AddScript(PSScriptStorage.GetCommand(null));
             var PSObjects = pipeline.Invoke();
             return PSObjects;
         }
     }));
 }