public string GetCalendarPermissions(string organization, string userprincipalname) { try { List <AjaxMailboxFolderPermission> folderPermissions = new List <AjaxMailboxFolderPermission>(); using (MyPowerShell ps = new MyPowerShell()) { ps.GetCalendarPermissions(organization, userprincipalname); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject folderPermission in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(folderPermission); folderPermissions.Add(new AjaxMailboxFolderPermission() { User = properties["User"].ToString(), AccessRights = properties["AccessRights"].ToString() }); } } return(new JavaScriptSerializer().Serialize(folderPermissions)); } catch (Exception exc) { return(new JsonException(exc).ToString()); } }