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

[玩转系统] 将邮箱权限导出到 CSV 文件

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

将邮箱权限导出到 CSV 文件


我们希望将邮箱权限导出到 Exchange Server 中的 CSV 文件。那是因为该公司正在与另一家公司合并,他们要求我们检查每个邮箱的权限。这些是邮箱和共享邮箱权限。我们可以登录Exchange管理中心并打开每个邮箱并记下用户的权限。这需要时间。如果我们可以使用一个强大的脚本来为我们完成工作怎么办?在本文中,您将了解如何将邮箱权限导出到 CSV 文件。

导出邮箱权限 PowerShell 脚本

该脚本将扫描邮箱数据库并一一检查邮箱。它将把正在执行的所有操作转储到文本文件,并将权限导出到 CSV 文件。此过程可能需要一些时间,因为这取决于 Exchange 组织的规模。在我的示例中,脚本运行需要 89 秒。它总共扫描了 38 个项目。

该脚本将检查以下内容的权限:

  • 邮箱

  • 通讯组

  • 资源邮箱

  • 共享邮箱

该脚本会将以下 Exchange 邮箱权限导出到 CSV 文件:

  • 发送为

  • 完全访问权限

  • 代寄

导出的 CSV 文件将包含每个邮箱权限的以下信息:

  • 显示名称

  • 主 SMTP 地址

  • 完全访问权限

  • 发送为权限

  • 代表发送权限

现在我们已经了解了脚本的功能,下一步是下载并设置它。之后,我们将运行脚本并检查导出的结果。

准备导出 Exchange 邮箱权限脚本

从此处(直接链接)或此处 (GitHub) 下载 Samuel F. Drey 制作的 PowerShell 脚本。如果没有提示您保存文件,请右键点击 Export-MailboxFASAPermissions.ps1,然后点击链接另存为。您应该能够保存脚本。将脚本放置在 C:\scripts 文件夹中。如果没有脚本文件夹,请创建一个。

[玩转系统] 将邮箱权限导出到 CSV 文件

将邮箱权限导出到 CSV 文件

登录到 Exchange Server 并以管理员身份运行 Exchange 命令行管理程序。默认 cmdlet 将导出所有邮箱的权限。这些是邮箱、通讯组、资源邮箱和共享邮箱。

[玩转系统] 将邮箱权限导出到 CSV 文件

更改脚本目录的路径并运行脚本。

[PS] C:\>cd scripts
[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-20-22-28-
02.csv
Checking if user specified -DistributionGroupsOnly switch...
Beginning routing to dump mailbox Send As, Full Access, and Send On Behalf permissions
Getting all databases
Processing Database DB01
The full mailbox command launched is :
Get-Mailbox -resultsize unlimited -database "DB01"
Parsing 37 mailboxes...
Working on mailbox Amanda Morgan which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
Found one or more SendOnBehalf Permission ! Dumping ...
Working on mailbox Christopher Payne which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
Found one or more SendOnBehalf Permission ! Dumping ...
Working on mailbox Mary Walsh which Primary SMTP is [email protected]
No custom Send As permissions detected
No custom Full Access permissions detected
No custom SendOnBehalf permissions detected

脚本完成后,将显示 CSV 文件。

[玩转系统] 将邮箱权限导出到 CSV 文件

验证 CSV 文件中的权限

该脚本在导出权限后将创建两个文件。找到导出的 CSV 文件。

[玩转系统] 将邮箱权限导出到 CSV 文件

使用您喜欢的程序打开 CSV 文件。我使用的是微软Excel。我们可以在一个简单的视图中看到邮箱的权限。

[玩转系统] 将邮箱权限导出到 CSV 文件

导出选定用户的邮箱权限

如果我们想导出单个用户或多个用户的邮箱权限怎么办?如果我们运行上述 cmdlet,它将搜索整个组织,这将需要时间。我和剧本的作者谈过,他帮助更新了剧本。他确实想出了一个新的-MailboxList参数。我们将利用该参数并添加要从中导出权限的用户的名称。

[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1 -MailboxList "Christopher Payne"
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-00-47-47.csv
Checking if user specified -DistributionGroupsOnly switch...
Using -MailboxList parameter, checking mailboxes from that list (1 mailboxes in the list)
Processing mailbox Christopher Payne
SUCCESS - Successfully located mailbox Christopher Payne : its primary SMTP address is : [email protected]
Working on mailbox Christopher Payne which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
Found one or more SendOnBehalf Permission ! Dumping ...
saving file in C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-00-47-47.csv


The script took 2.5061906 seconds to execute...

如果我们想导出多个用户的权限,我们需要添加用逗号分隔的用户。

[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1 -MailboxList "Christopher Payne", "Emma Underwood"
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-00-48-28.csv
Checking if user specified -DistributionGroupsOnly switch...
Using -MailboxList parameter, checking mailboxes from that list (2 mailboxes in the list)
Processing mailbox Christopher Payne
SUCCESS - Successfully located mailbox Christopher Payne : its primary SMTP address is : [email protected]
Working on mailbox Christopher Payne which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
Found one or more SendOnBehalf Permission ! Dumping ...
Processing mailbox Emma Underwood
SUCCESS - Successfully located mailbox Emma Underwood : its primary SMTP address is : [email protected]
Working on mailbox Emma Underwood which Primary SMTP is [email protected]
No custom Send As permissions detected
No custom Full Access permissions detected
No custom SendOnBehalf permissions detected
saving file in C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-00-48-28.csv


The script took 4.8661493 seconds to execute...

将共享邮箱权限导出到 CSV 文件

在第一部分中,我们了解了如何导出所有邮箱的权限。在第二部分中,我们确实导出了单个用户或指定用户的权限。可以仅导出共享邮箱权限。

[玩转系统] 将邮箱权限导出到 CSV 文件

让我们使用 -SharedMailboxes 参数。

[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1 -SharedMailboxes
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-22-12-
30.csv
Checking if user specified -DistributionGroupsOnly switch...
Beginning routing to dump mailbox Send As, Full Access, and Send On Behalf permissions
Getting all databases
Processing Database DB01
Specified Resource Mailboxes parameter ? False
Specified SharedMailboxes parameter ? True
The full mailbox command launched is :
Get-Mailbox -resultsize unlimited -database "DB01" -RecipientTypeDetails SharedMailbox
Parsing 3 mailboxes...
Working on mailbox Shared Info which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
No custom SendOnBehalf permissions detected
Working on mailbox Shared Sales which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
No custom SendOnBehalf permissions detected
Working on mailbox Shared HR which Primary SMTP is [email protected]
Found one or more SendAs Permission ! Dumping ...
Found one or more Full Access Permission ! Dumping ...
No custom SendOnBehalf permissions detected
saving file in C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-22-12-30.csv


The script took 7.904148 seconds to execute...

将资源邮箱权限导出到CSV文件

如果我们只想导出资源邮箱权限怎么办?

[玩转系统] 将邮箱权限导出到 CSV 文件

我们可以使用-ResourceMailboxes参数。

[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1 -DistributionGroupsOnly
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-22-40-28.csv
Checking if user specified -DistributionGroupsOnly switch...
User specified the -DistribugionGroupsOnly switch. Beginning Distribution Groups SendAs / GrantSendOnBehalfTo permissions dump...
Getting all distribution Groups
Testing whether the user set the -IncludeDynamic boolean parameter to $false ($true by default)
User didn't specify the -IncludeDynamic or set -IncludeDynamic to $false - including Dynamic DLs
Working on Distribution Group Management which Primary SMTP is [email protected]
No custom Send As permissions detected
Found one or more SendOnBehalf Permission ! Dumping ...
saving file in C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-21-22-40-28.csv


The script took 2.8954808 seconds to execute...

将通讯组权限导出到 CSV 文件

最后,我们希望将通讯组权限导出到 CSV 文件。

[玩转系统] 将邮箱权限导出到 CSV 文件

我们可以使用-DistributionGroupsOnly参数。

[PS] C:\scripts>.\Export-MailboxFASAPermissions.ps1 -DistributionGroupsOnly
********************** Beginning execution ***********************
Testing if Exchange tools are present

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-Mailbox                                        1.0        ex01-2016.exoip.local
Exchange tools are present !
True
Exchange Tools present ! continuing to test if user specified Output file
Not Output file specified, using the script standard name C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-20-22-45-18.csv
Checking if user specified -DistributionGroupsOnly switch...
User specified the -DistribugionGroupsOnly switch. Beginning Distribution Groups SendAs / GrantSendOnBehalfTo permissions dump...
Getting all distribution Groups
Testing whether the user set the -IncludeDynamic boolean parameter to $false ($true by default)
User didn't specify the -IncludeDynamic or set -IncludeDynamic to $false - including Dynamic DLs
Working on Distribution Group Management which Primary SMTP is [email protected]
No custom Send As permissions detected
Found one or more SendOnBehalf Permission ! Dumping ...
saving file in C:\scripts\Export-MailboxFASAPermissions.ps1_2020-05-20-22-45-18.csv


The script took 2.259128 seconds to execute...

现在您已经知道如何将邮箱权限导出到 CSV 文件,您会使用该脚本吗?

结论

在本文中,您学习了如何将邮箱权限导出到 CSV 文件。这是一个很棒的脚本,如果您需要导出,我建议您使用它。下次您想要审核 Exchange 组织时,请不要忘记使用脚本检查权限。

您喜欢这篇文章吗?您可能还想阅读安装 Exchange 累积更新。不要忘记关注我们并分享这篇文章。

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

取消回复欢迎 发表评论:

关灯