【问题标题】:How to get a list of all the Shared Mailboxes that a user have access to Exchange2010 | Exchange Management Shell or PowerShell?如何获取用户有权访问 Exchange2010 的所有共享邮箱的列表Exchange 命令行管理程序还是 PowerShell?
【发布时间】:2018-12-22 06:56:04
【问题描述】:

获取邮箱 |获取邮箱权限 -user

获取邮箱 | Get-MailboxPermission -user |其中 {$_.AccessRights -like "sendas*"}

获取邮箱 |获取 ADPermission |其中 {$_.extendedRights -like "send-as"}

以上所有命令都不适合我

【问题讨论】:

    标签: powershell scripting exchange-management-shell


    【解决方案1】:

    我会做这样的事情。它将输出所有共享邮箱和有权访问它的用户。对于每个用户,它都会显示邮箱的访问权限。根据用户和共享邮箱的数量,处理可能需要一段时间。

    (由于[ordered],您需要Powershell 版本3 或更高版本。要在Powershell 2 中使用它,请删除[ordered]。届时无法保证显示属性的顺序。)

    function Get-AllMailboxPermissions {
        $allMailboxes = Get-Mailbox -ResultSize Unlimited | Sort-Object Identity
    
        if ($allMailboxes.Count -eq 0) {
            Write-Warning "No mailboxes found."
            return
        }
        foreach ($box in $allMailboxes) {
            $perms = $box | Get-MailboxPermission |
                            Where-Object { $_.IsInherited -eq $false -and $_.User.ToString() -ne "NT AUTHORITY\SELF" -and $_.User.ToString() -notmatch '^S-1-' } |
                            Sort-Object User
    
            foreach ($prm in $perms) {
                $user = Get-Recipient -Identity $($prm.User.ToString()) -ErrorAction SilentlyContinue
                # skip inactive (deleted) users
                if ($user -and $user.DisplayName) { 
                    $props = [ordered]@{
                        "Mailbox"      = "$($box.Identity)"
                        "User"         = $user.DisplayName
                        "AccessRights" = "$($prm.AccessRights -join ', ')"
                    }
                    New-Object PsObject -Property $props
                }
            }
        }
    }
    

    您可能希望将此信息保存在 csv 文件中。在这种情况下,像这样调用函数:

    Get-AllMailboxPermissions | Export-Csv -Path '<PATH-TO-OUTPUT.CSV>' -NoTypeInformation -Encoding UTF8 -Force
    

    提示:如果您希望能够通过在同一台计算机上双击它来在 Excel 中打开 csv,Export-Csv cmdlet 有一个非常有用的开关 -UseCulture。这样,csv 文件中的分隔符将与 Excel 所期望的相同。

    【讨论】:

      【解决方案2】:

      我终于可以使用下面的这个脚本了,在 Microsoft Exchange 命令行管理程序中运行这个脚本,确保在命令行管理程序中运行脚本之前执行策略全部被授予

      对用户邮箱和共享邮箱具有完全访问权限的用户

      获取邮箱 | Get-MailboxPermission -user $user |其中 {($.AccessRights -eq "FullAccess") -and -not ($.User -eq "NT AUTHORITY\SELF")} |格式表标识,用户

      具有代理发送权限的用户

      获取邮箱 |获取 ADPermission -user $user |其中 {($.ExtendedRights -eq "*send-as*") -and -not ($.User -eq "NT AUTHORITY\SELF")} | Format-Table Identity,User

      【讨论】:

      • 您的问题是如何获取用户有权访问 Exchange 2010Exchange2010 的所有共享邮箱的列表 | Exchange 命令行管理程序还是 PowerShell?。您现在显示的代码仅显示部分访问权限。我的回答显示了所有特权,这正是您所要求的......
      猜你喜欢
      • 2018-02-01
      • 2020-09-10
      • 2017-05-05
      • 1970-01-01
      • 2015-09-07
      • 2010-10-11
      • 1970-01-01
      • 2013-12-17
      • 1970-01-01
      相关资源
      最近更新 更多