public string GetCALMailbox(string organization, string name) { try { List <AjaxMailbox> calmailboxes = new List <AjaxMailbox>(); using (MyPowerShell ps = new MyPowerShell()) { ps.GetMailbox(organization, name); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject mailbox in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(mailbox); calmailboxes.Add(new AjaxMailbox() { Name = properties["Name"].ToString(), UserPrincipalName = properties["UserPrincipalName"].ToString(), RecipientTypeDetails = properties["RecipientTypeDetails"].ToString(), EmailAddresses = properties["EmailAddresses"].ToString().Split(' ') }); } } return(new JavaScriptSerializer().Serialize(calmailboxes)); } catch (Exception exc) { return(new JsonException(exc).ToString()); } }