// Alias: Get-VMSwitch public static List <PSObject> GetVmSwitch(string ComputerName) { Collection <PSObject> res; PSWrapper.FastExecute(ComputerName, "Get-VMSwitch", out res); return(res.ToList()); }
// Alias: Get-VHD public static List <PSObject> GetVhd(string ComputerName, string Path, PsStreamEventHandlers handlers = null) { Collection <PSObject> res; res = PSWrapper.FastExecute(ComputerName, (ps) => { return(ps.AddCommand("Get-VHD").AddParameter("Path", Path).Invoke()); }, handlers); return(res.ToList()); }
// Alias: Get-VM /// <exception cref="Exception">May throw exceptions</exception> public static VirtualMachine GetVm(string hostName, string Name, PsStreamEventHandlers handlers = null) { Collection <PSObject> objs = null; PSWrapper.FastExecute(hostName, $"Get-Vm -Name \"{Name}\"", out objs, handlers); if (objs == null || objs.Count == 0) { return(null); } return(VirtualMachine.FromPSObject(objs[0], hostName)); }
// Alias: Get-VM /// <exception cref="Exception">May throw exceptions</exception> public static List <VirtualMachine> GetVm(string hostName, PsStreamEventHandlers handlers = null) { Collection <PSObject> objs = null; PSWrapper.FastExecute(hostName, "Get-Vm", out objs, handlers); if (objs == null || objs.Count == 0) { return(new List <VirtualMachine>()); } List <VirtualMachine> machines = new List <VirtualMachine>(); foreach (var m in objs) { machines.Add(VirtualMachine.FromPSObject(m, hostName)); } return(machines); }
public static void DeleteItem(string host, string path) { Collection <PSObject> res = null; PSWrapper.FastExecute(host, $"Remove-Item –Path \"{path}\"", out res); }