如何从 Powershell 获取当前和存档邮箱大小?

How to get current and archive mailbox sizes from Powershell?

我是 PowerShell 的新手,所以在我还是新手和学习的同时,我非常依赖 Microsoft 文档。我正在尝试收集我们用户当前邮箱和他们的存档邮箱的大小,以便更改我们公司的保留政策。我知道我可以从 Exchange 在线获取存档邮箱 size/percentage,但我想一次获取我们所有的用户,而不是一次一个用户手动收集此信息。

我一直在关注微软文档,但我没有得到我想要的结果。

我有 运行 一些命令,它们 return 结果如预期,但我不熟悉如何正确地从 Office365 中获取我需要的信息。

如能提供任何帮助,我将不胜感激,以免我的头撞到桌子上!

我关注的微软文档:

https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailboxfolderstatistics?view=exchange-ps

https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailbox?view=exchange-ps

https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailboxfolder?view=exchange-ps

我拥有 运行 并得到结果的 Microsoft 文档中的命令,只是不是我需要的信息。

Get-MailboxFolderStatistics -Identity Company\FirstName.LastName

Get-MailboxStatistics -Identity Company\FirstName.LastName

Get-Mailbox -Archive -ResultSize unlimited |导出-CSV C:\Archives.csv

当我 运行 上面的命令时,我确实得到了结果,但我没有得到用户邮箱或其存档邮箱的确切大小。

对于邮箱的大小,get-mailboxstatistics 将满足您的需求。只要确保您使用的是正确的属性即可:

get-MailboxStatistics username | select displayname,totalitemsize4
Get-MailboxFolderStatistics -Identity username | select name,foldersize
Get-MailboxFolderStatistics -Archive -Identity username | select name,foldersize