private static Task <Either <PowershellFailure, Seq <TypedPsObject <VirtualMachineInfo> > > > GetVmInfo(string id,
                                                                                                                IPowershellEngine engine) =>

        Prelude.Cond <string>((c) => !string.IsNullOrWhiteSpace(c))(id).MatchAsync(
            None:  () => Seq <TypedPsObject <VirtualMachineInfo> > .Empty,
            Some: (s) => engine.GetObjectsAsync <VirtualMachineInfo>(PsCommandBuilder.Create()
                                                                     .AddCommand("get-vm").AddParameter("Id", s)
                                                                     //this a bit dangerous, because there may be other errors causing the
                                                                     //command to fail. However there seems to be no other way except parsing error response
                                                                     .AddParameter("ErrorAction", "SilentlyContinue")
                                                                     ));
示例#2
0
 public Task Handle(InventoryRequestedEvent message) =>
 _engine.GetObjectsAsync <MinimizedVirtualMachineInfo>(PsCommandBuilder.Create()
                                                       .AddCommand("get-vm"))
 .ToAsync()
 .IfRightAsync(vms => _bus.Send(VmsToInventory(vms)));
 protected virtual PsCommandBuilder CreateGetVMCommand(Guid vmId)
 {
     return(PsCommandBuilder.Create()
            .AddCommand("get-vm").AddParameter("Id", vmId));
 }