public string GetSendAsGroups(string organization) { try { List <AjaxSendAsGroups> groups = new List <AjaxSendAsGroups>(); using (MyPowerShell ps = new MyPowerShell()) { ps.GetSendAsGroups(organization); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject Group in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(Group); groups.Add(new AjaxSendAsGroups() { Name = properties["Name"].ToString(), DistinguishedName = properties["DistinguishedName"].ToString(), Description = properties["Description"].ToString(), }); } } return(new JavaScriptSerializer().Serialize(groups)); } catch (Exception exc) { return(new JsonException(exc).ToString()); } }