0

So I have the following script - whereby I want to export both Get-Mailbox information, and Get-MailboxStatistics information as I understand they both handle different aspects of the mailbox with regards to the information we can export about.

Get-Mailbox -Server Server01 -ResultSize unlimited |
 Where {$_.UseDatabaseQuotaDefaults -eq $false} |
   ft DisplayName,IssueWarningQuota,ProhibitSendQuota,@{label="TotalItemSize(MB)";expression={(Get-MailboxStatistics $_).TotalItemSize.Value.ToMB()}}

Problem 1: is I get no information in the TotalItemSize field when I run the script Problem 2: If I add | Export-CSV C:\test.csv I get garbage!

Any ideas?

PnP
  • 3,133
  • 17
  • 62
  • 95

1 Answers1

1

You're getting garbage on the export-csv because you're trying to export format-table data. Trade that format-table for select-object and it'll work better.

$MBXs = Get-Mailbox -Server Server01 -ResultSize Unlimited |
 Where {$_.UseDatabaseQuotaDefaults -eq $false} 

 &{
 foreach ($MBX in $MBXs)
  {$MBX | select DisplayName,IssueWarningQuota,ProhibitSendQuota,@{label="TotalItemSize(MB)";expression={(Get-MailboxStatistics $MBX).TotalItemSize.Value.ToMB()}}}
  }|export-csv mbxquotas.csv
mjolinor
  • 66,130
  • 7
  • 114
  • 135
  • Thanks! How could I also get the Quota to display as MB and not GB like the TotalItemSize? – PnP Mar 26 '13 at 21:28