public string GetVMVHDs(string vmid) { try { List <AjaxVMVHDs> vhds = new List <AjaxVMVHDs>(); using (MyPowerShell ps = new MyPowerShell()) { ps.GetVMVHDs(vmid); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject VHD in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(VHD); vhds.Add(new AjaxVMVHDs() { Name = properties["Name"].ToString(), VHDID = properties["VHDID"].ToString(), Size = properties["Size"].ToString(), }); } } return(new JavaScriptSerializer().Serialize(vhds)); } catch (Exception exc) { return(new JsonException(exc).ToString()); } }