导出邮箱大小和存档大小到相同的文件

我需要将邮箱大小和存档大小导出到相同的csv文件。

我知道导出我需要使用Get-Mailbox |的邮箱大小 Get-MailboxStatistics | select-object Displayname,totalitemsize | export-csv。\ filename.csv

获取档案大小,我需要使用Get-Mailbox | Get-MailboxStatistics -archive | select对象totalitemsize | export-csv。\ filename.csv

我需要知道如何在这两个命令之间进行匹配。

预先感谢。 亚伯拉罕。

我想一个哈希表,它是什么你后

https://technet.microsoft.com/en-us/library/ee692803.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2011/10/15/automatically-create-a-powershell-hash-table-10-15-11.aspx

基本上你定义了一个表,例如:MailboxName,ActiveSize,ArchiveSize

创build一个循环,从$那里得到$这个值。 $从$这里

冲洗并重复

编辑:我没有testing过,但应该给出基本的想法

$objTABLE = @() ForEach ($iMailbox in (Get-Mailbox -ResultSize "Unlimited")) { $objTABLE += New-Object psobject -Property @{MailboxName=$(Get-Mailbox -Idendity $iMailbox | Select DisplayName); ActiveSize=$(Get-MailboxStatistics -Idendity $iMailbox | select totalitemsize); ArchiveSize=$(Get-MailboxStatistics -Archive | select-object totalitemsize)} } $objTABLE | Out-GridView 

谢谢你的回答,它帮助我创build了我所需要的报告。

这是我需要的报告:

 $Mailboxes = @(get-Mailbox) $report = @() foreach ($Mailbox in $Mailboxes) { $mailboxonly = Get-Mailbox $Mailbox $mailboxstate = Get-Mailbox $Mailbox | Get-MailboxStatistics $mailboxstateA = Get-Mailbox $Mailbox | Get-MailboxStatistics -archive $inpObj = New-Object PSObject $inpObj | Add-Member -MemberType NoteProperty -Name "Display Name" -Value $mailboxstate.DisplayName $inpObj | Add-Member -MemberType NoteProperty -Name "PrimarySmtpAddress" -Value $mailboxonly.PrimarySmtpAddress $inpObj | Add-Member -MemberType NoteProperty -Name "Database" -Value $mailboxstate.Database $inpObj | Add-Member -MemberType NoteProperty -Name "MailboxSize" -Value $mailboxstate.totalitemsize $inpObj | Add-Member -MemberType NoteProperty -Name "ArchiveDatabase" -Value $mailboxonly.ArchiveDatabase $inpObj | Add-Member -MemberType NoteProperty -Name "ArchiveSizeenter image description here" -Value $mailboxstateA.TotalItemSize $report += $inpObj } $report 

谢谢你的帮助!