循环遍历每个数据库以提取“代理发送权限”

时间:2016-04-15 02:22:06

标签: powershell exchange-server

我尝试从Exchange 2010服务器获取“代理发送”权限。

我一直遇到一个错误,即从远程客户端收到的总数据超出了允许的最大值。允许的最大值为524288000。

作为一种减轻这种情况的方法,我考虑在每个数据库的foreach循环中运行命令。

我的问题是,我怎样才能让它发挥作用?不幸的是,上面的脚本不起作用。

@WebServlet(urlPatterns="/search", displayName="ControllerServlet")
public class ControllerServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    Logger logger = Logger.getLogger(this.getClass().getName());

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ControllerServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub

        String action = ((ServletRequest) request.getSession()).getParameter("action");

        System.out.println("Action: " + action);

        // get the songs and albums objects containing data needed from session
        ArrayList<SongBean> songs = (ArrayList<SongBean>) request.getSession().getAttribute("songs");
        ArrayList<AlbumBean> albums = (ArrayList<AlbumBean>) request.getSession().getAttribute("albums");

        // initialize nextPage empty String
        String nextPage = "";

        if (action.equals("search")) {
            String content = request.getParameter("content");
            String options = request.getParameter("options");

                    // when nothing entered in search box
                    if (content.length() == 0) {
                        nextPage = "search.jsp";
                        System.out.println("Nothing");
                    // when something entered in search box
                    } else {
                        // check what Advanced Search option is selected (default = Anything)
                        if (options.equals("Songs")) {
                            System.out.println("Songs selected");
                            // setting the context so results.jsp knows what tables to return
                            request.getSession().setAttribute("searchType", "songs");
                            ArrayList<SongBean> resultsArray = new ArrayList<SongBean>();

                            for (SongBean song : songs) {
                                if (song.getTitle().contains(content)) {
                                       resultsArray.add(song);
                                   }
                            }

                            request.getSession().setAttribute("searchresults", resultsArray);
                    }

                    // need to getSession as well to make results available to all in session

                    }
                }
        RequestDispatcher requestdispatcher = request.getRequestDispatcher("/results.jsp");

        requestdispatcher.forward(request, response);
    }

}

2 个答案:

答案 0 :(得分:0)

我没有exch服务器来测试这个,但你可以尝试以下方法:

$databases = Get-MailboxDatabase -Server $yourserver

$databases | 
 Get-Mailbox -resultsize unlimited  
   Get-ADPermission | 
     Where-Object{($_.ExtendedRights -like '*send-as*') -and (-not ($_.User -like 'nt authorityself'))} | 
        Select-Object Identity, User | 
          export-csv -Path 'c:\temp\mbx.csv' -NoTypeInformation

在你的帖子中,export-csv内的foreach会在每次循环运行时覆盖该文件。

答案 1 :(得分:0)

试试这个:

$allmbxinyourorg = Get-Mailbox -ResultSize unlimited
Foreach ($mbx in $allmbxinyourorg) 
{
    Get-Mailbox -database $mbx | 
     Get-ADPermission | 
       ?{($_.ExtendedRights -like "*send-as*") -and -not ($_.User -like "nt authorityself")} |
         Select Identity, User | 
           export-csv -notypeinformation 'mbx.csv' -Append
}

你能发布你得到的确切错误吗? 你何时遇到例外?

$ allmbxinyourorg = Get-Mailbox -ResultSize unlimited 还是在另一步?