Export Mailbox Size and Archive Size to the same file
Solution 1
I think a hash table it what you're after
https://technet.microsoft.com/en-us/library/ee692803.aspx
Basically you define a table, eg: MailboxName, ActiveSize, ArchiveSize
Create a loop, get $This value from $There . $That from $Here
Rinse and repeat
Edit: I haven't tested this, but should give the basic idea
$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
Solution 2
thank you for your answer it helped me a little to build the report I needed.
This is the report I needed:
$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
Thank for the help!
Related videos on Youtube
gavraham
Updated on September 18, 2022Comments
-
gavraham over 1 year
I need to export mailbox Size and Archive size to the same csv file.
I know to export the mailbox size I need to use Get-Mailbox | Get-MailboxStatistics | select-object Displayname,totalitemsize | export-csv .\filename.csv
to get archive size I need to use Get-Mailbox | Get-MailboxStatistics -archive | select-object totalitemsize | export-csv .\filename.csv
I need to know how to marge between this two commands.
Thank in advance. Avraham.
-
Sunzi over 8 yearsTry Get-Help Export-csv -Online in powershell. And then look after Parameter -NoClobber. Is it really faster to post a question than to take a quick look at the parameters of used commands?
-