当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何导出完全访问邮箱权限

作者:精品下载站 日期:2024-12-14 05:50:19 浏览:16 分类:玩电脑

如何导出完全访问邮箱权限


您可以导出对许可的 Microsoft 365 邮箱具有完全访问权限的用户列表。通过这种方式,您可以查看哪些用户可以打开 Microsoft 365 邮箱并充当邮箱所有者。在本文中,您将了解如何使用 Exchange Online PowerShell 导出完全访问邮箱权限。

连接到 Exchange Online PowerShell

为了能够运行 PowerShell 命令,您必须连接到 Exchange Online PowerShell。以管理员身份打开 Windows PowerShell,运行以下 cmdlet,然后使用管理员凭据登录。

Connect-ExchangeOnline

导出单个用户的完全访问邮箱权限

我们将向您展示如何使用 PowerShell 导出用户邮箱的邮箱权限。

我们想要获取有关其他用户对特定用户邮箱拥有的邮箱权限的信息。我们用于显示邮箱权限的 PowerShell cmdlet 是 Get-MailboxPermission。

[玩转系统] 如何导出完全访问邮箱权限

在我们的示例中,我们希望显示哪些用户(或组)对 Brenda 的邮箱具有完全访问邮箱权限。

我们将使用-AutoSize参数来减少结果列之间的空间。

运行以下 PowerShell 命令。

Get-MailboxPermission "[email protected]" | ft -AutoSize

查看PowerShell输出结果。

Identity                             User                     AccessRights                 IsInherited Deny
--------                             ----                     ------------                 ----------- ----
0f38d53f-cbe0-4844-86e9-1032a45ba31b NT AUTHORITY\SELF        {FullAccess, ReadPermission} False       False
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}                 False       False
0f38d53f-cbe0-4844-86e9-1032a45ba31b Finance UK mail list     {FullAccess}                 False       False
0f38d53f-cbe0-4844-86e9-1032a45ba31b Sales Norway             {FullAccess}                 False       False
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}                 False       False

输出显示您提供的邮箱(Brenda)身份,并在用户列下列出具有完全访问权限的邮箱。

从技术上讲,我们得到了所需的结果,但如果我们更深入地研究数据,就会发现一些问题。

当我们使用基本的PowerShell命令在Exchange Online中显示邮箱权限时,会出现很多不相关的信息。首先,我们要删除每个用户对其邮箱拥有的 SELF 权限。然后,我们要从显示的结果中删除 IsInherited 权限。

为了清除不必要的信息,我们将使用逻辑条件(Where)来排除分类为NT AUTHORITY\SELFIsInherited完全访问邮箱权限强>。

运行以下 PowerShell 命令示例。

Get-MailboxPermission "[email protected]" | Where { ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") } | Ft Identity, User, AccessRights -AutoSize

PowerShell输出结果如下所示。

Identity                             User                     AccessRights
--------                             ----                     ------------
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b Finance UK mail list     {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b Sales Norway             {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}

我们可以看到,我们成功地排除或清除了大部分不相关的信息。它显示对 Brenda 邮箱具有完全访问邮箱权限的邮箱。

导出多个用户的完全访问邮箱权限

您还可以获取多个用户的邮箱权限。在我们的示例中,我们想知道谁拥有 Brenda SmithKen Walker 的邮箱权限。

在PowerShell命令中,我们可以添加用逗号分隔的每个用户名。

请参阅下面的 PowerShell 命令语法。

"[email protected]","[email protected]" | ForEach {Get-MailboxPermission -Identity $_}

为了删除输出中的不相关信息,我们将更改上面的 PowerShell 命令。

运行 PowerShell 命令示例。

"[email protected]","[email protected]" | ForEach { Get-MailboxPermission -Identity $_ | Where { ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") -and -not ($_.User -like '*Discovery Management*') } } | Select Identity, User, AccessRights

PowerShell输出结果如下所示。

Identity                             User                     AccessRights
--------                             ----                     ------------
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b Finance UK mail list     {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b Sales Norway             {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] {FullAccess}
12eefbb2-e5f4-4eec-bd18-df7ca2f1ee6b [email protected]  {FullAccess}
12eefbb2-e5f4-4eec-bd18-df7ca2f1ee6b [email protected]   {FullAccess}

它将在您提供的邮箱(Brenda Smith & Ken Walker)用户列下列出具有完全访问权限的所有邮箱。

导出完全访问权限用户有权访问

我们想要导出特定用户有权访问其他用户或组的完全访问邮箱权限。

[玩转系统] 如何导出完全访问邮箱权限

要获取该信息,我们需要使用 Get-Mailbox cmdlet 来获取所有现有邮箱的列表。然后,我们还将使用 Get-MailboxPermission cmdlet 并添加用户名。

PowerShell 命令将检查所有邮箱阵列,检查用户具有邮箱权限的邮箱,并显示结果。 PowerShell 命令的其余部分用于改进 Get-MailboxPermission cmdlet 显示的结果。

在我们的示例中,我们希望获取有关用户 Brenda Smith 对其他邮箱的完全访问权限的信息。

  1. 第 1 行中指定邮箱
  2. 运行以下 PowerShell 命令脚本
Get-Mailbox -Resultsize Unlimited | Get-MailboxPermission -User "[email protected]" | ForEach-Object {
    $mailbox = Get-Mailbox $_.Identity
    $User = Get-Mailbox $_.User
    [PSCustomObject]@{
        UserId            = $User.Identity
        User              = $_.User
        Identity          = $_.Identity
        UserPrincipalName = $mailbox.UserPrincipalName
        AccessRights      = $_.AccessRights
    }
} | Format-Table UserId, User, Identity, UserPrincipalName, AccessRights

PowerShell 输出显示 Brenda Smith 拥有完全访问权限的邮箱列表。

UserId                               User                      Identity                             UserPrincipalName      AccessRights
------                               ----                      --------                             -----------------      ------------
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] 82cd0d62-e974-4892-aca6-e0387abc62be [email protected] {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] Catch All                            [email protected] {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] Info Box                             [email protected]   {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] 12eefbb2-e5f4-4eec-bd18-df7ca2f1ee6b [email protected]… {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] Projector 21                         Projector21@a-d.… {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] RoomTest8                            [email protected] {FullAccess}
0f38d53f-cbe0-4844-86e9-1032a45ba31b [email protected] c32b2b27-d809-439a-a3e3-eb7a749eeb72 Stephen.Hunter@m365in… {FullAccess}

您指定的具有完全访问权限的邮箱信息([email protected])列在UserIdUser 列下。它在身份UserPrincipalName列下显示所有 Exchange Online 邮箱的列表。

将具有完全访问权限的邮箱列表导出到 CSV 文件

我们希望将具有完全访问邮箱权限的所有用户列表导出到 CSV 文件和 Out-GridView。它显示对另一个许可邮箱具有完全访问邮箱权限的每个邮箱。

请按照以下步骤将邮箱权限列表导出到 CSV:

  1. 创建 temp 文件夹并将其保存在 (C:) 驱动器(如果您还没有)
  2. 在第 第 2 行 中输入 CSVPath
  3. 运行以下 PowerShell 脚本
# Set the path for the CSV file to store the permissions
$CSVPath = "C:\temp\FullAccessPerms.csv"

try {
    # Get all the mailboxes with unlimited result size and retrieve their mailbox permissions
    $permissions = Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | Where-Object {
        # Filter out permissions that are inherited, belong to "NT AUTHORITY\SELF", or belong to "Discovery Management"
        ($_.IsInherited -eq $false) -and -not ($_.User -like "NT AUTHORITY\SELF") -and -not ($_.User -like '*Discovery Management*')
    } | ForEach-Object {
        # For each permission, get the mailbox details
        $mailbox = Get-Mailbox $_.Identity
        [PSCustomObject]@{
            UserPrincipalName    = $mailbox.UserPrincipalName
            Identity             = $mailbox.Identity
            User                 = $_.User
            AccessRights         = $_.AccessRights
            RecipientTypeDetails = $mailbox.RecipientTypeDetails
        }
    } | Select-Object Identity, UserPrincipalName, User, AccessRights, RecipientTypeDetails

    # Display the permissions in Out-GridView
    $permissions | Out-GridView -Title "Full Access mailbox permissions"

    # Export the permissions to a CSV file
    $permissions | Export-Csv -Path $CSVPath -NoTypeInformation -Encoding UTF8

    # Display a success message if the export was successful
    Write-Host "Exported permissions successfully to $CSVPath" -ForegroundColor Cyan
}
catch {
    # Display an error message if there was an exception during the export
    Write-Host "Error exporting permissions: $_" -ForegroundColor Red
}
  1. 运行脚本后会出现 Out-GridView

[玩转系统] 如何导出完全访问邮箱权限

  1. C:\temp 文件夹中查找 CSV 文件
  2. 使用 Microsoft Excel 等应用程序打开 CSV 文件以查看结果

[玩转系统] 如何导出完全访问邮箱权限

就是这样!

了解更多:使用 Microsoft Graph PowerShell 导出 Azure AD 用户 »

结论

您了解了如何使用 Exchange Online PowerShell 导出完全访问邮箱权限。使用 Get-MailboxPermission PowerShell cmdlet,您可以获取对单个或所有 Microsoft 365 邮箱具有完全访问权限的用户列表。

您喜欢这篇文章吗?您可能还喜欢使用 PowerShell 将 Azure AD 组成员导出到 CSV。不要忘记关注我们并分享这篇文章。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯