public string GetDistributionGroups(string organization) { try { List <AjaxDistributionGroup> distributionGroups = new List <AjaxDistributionGroup>(); using (MyPowerShell ps = new MyPowerShell()) { ps.GetDistributionGroups(organization); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject group in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(group); distributionGroups.Add(new AjaxDistributionGroup() { Name = properties["DisplayName"].ToString(), PrimarySmtpAddress = properties["PrimarySmtpAddress"].ToString() }); } } return(new JavaScriptSerializer().Serialize(distributionGroups)); } catch (Exception exc) { return(new JsonException(exc).ToString()); } }