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

[玩转系统] 使用 PowerShell 列出 Exchange 数据库中的邮箱

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

使用 PowerShell 列出 Exchange 数据库中的邮箱


查找 Exchange 数据库上的邮箱的一个好方法是使用 PowerShell。使用 Exchange 命令行管理程序,您可以立即查看数据库中存在哪些邮箱。在本文中,您将了解如何列出数据库中的邮箱。

获取邮箱数据库名称

在开始之前,您需要知道邮箱数据库名称。以管理员身份运行 Exchange 命令行管理程序。

使用 Get-MailboxDatabase cmdlet 获取所有邮箱数据库。使用-Status开关检查邮箱数据库安装状态。使用-InincludePreExchange 开关获取旧版 Exchange 服务器中的邮箱数据库。

注意:记住要挂载邮箱数据库。否则,您无法列出邮箱。

[PS] C:\>Get-MailboxDatabase -Status -IncludePreExchange | Sort Name | Format-Table Name, Server, Mounted

Name Server    Mounted
---- ------    -------
DB01 EX01-2016    True
DB02 EX02-2016    True
DB03 EX01-2016    True
DB04 EX02-2016    True

了解更多:使用 PowerShell 获取 Exchange 邮箱数据库安装状态 »

在下一步中,我们将列出 Exchange 数据库中的所有邮箱。

列出数据库中的所有邮箱

找出邮箱数据库中有哪些邮箱。在此示例中,我们将检查邮箱数据库DB02

[PS] C:\>Get-Mailbox -Database "DB02" | ft Name, Alias, WindowsEmailAddress, UserPrincipalName

Name            Alias           WindowsEmailAddress       UserPrincipalName
----            -----           -------------------       -----------------
Piers Bower     Piers.Bower     [email protected]     [email protected]
Richard Grant   Richard.Grant   [email protected]   [email protected]
Nicholas Murray Nicholas.Murray [email protected] [email protected]
Ruth Dickens    Ruth.Dickens    [email protected]    [email protected]
Jonathan Fisher Jonathan.Fisher [email protected] [email protected]
Grace Rees      Grace.Rees      [email protected]      [email protected]
Patrick Mors    Patrick.Mors    [email protected]    [email protected]

注意以上命令不会显示邮箱数据库中是否存在存档邮箱。

找出邮箱数据库中的存档邮箱。在此示例中,我们将检查邮箱数据库DB02

[PS] C:\>Get-Mailbox | Where {$_.ArchiveDatabase -like "DB02"} | ft Name, Alias, WindowsEmailAddress, UserPrincipalName

Name            Alias           WindowsEmailAddress       UserPrincipalName
----            -----           -------------------       -----------------
Hannah Duncan   Hannah.Duncan   [email protected]   [email protected]
Hasan Hamza     Hasan.Hamza     [email protected]     [email protected]
Jonathan Fisher Jonathan.Fisher [email protected] [email protected]
Max Gibson      Max.Gibson      [email protected]      [email protected]
Piers Bower     Piers.Bower     [email protected]     [email protected]
Richard Grant   Richard.Grant   [email protected]   [email protected]
Simon Berry     Simon.Berry     [email protected]     [email protected]

将数据库中的所有邮箱导出到 CSV 文件

将所有邮箱导出到目录 C:\temp 中的 CSV 文件。如果没有临时文件夹,请创建一个。

[PS] C:\>Get-Mailbox -Database "DB02" | select Name, Alias, WindowsEmailAddress, UserPrincipalName | Export-Csv "C:\temp\MailboxesDB02.csv" -NoTypeInformation -Encoding UTF8
[PS] C:\>Get-Mailbox | Where {$_.ArchiveDatabase -like "DB02"} | select Name, Alias, WindowsEmailAddress, UserPrincipalName | Export-Csv "C:\temp\ArchiveMailboxesDB02.csv" -NoTypeInformation -Encoding UTF8

使用 Microsoft Excel 或您选择的其他喜爱的应用程序打开 CSV 文件。

继续阅读:确定邮箱是在本地还是在 Office 365 中 »

结论

您学习了如何使用 PowerShell 列出 Exchange 数据库中的邮箱。在迁移邮箱、删除邮箱数据库之前,或者在数据库出现问题并且想要查看邮箱是否位于该数据库中时,最好了解数据库中存在哪些邮箱。 PowerShell cmdlet 非常好用。

您喜欢这篇文章吗?您可能喜欢添加数据库副本 Exchange Server。不要忘记关注我们并分享这篇文章。

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

取消回复欢迎 发表评论:

关灯