eb17 eb17 - 1 year ago 114
PowerShell Question

Selected mailbox information missing in exported CSV file

I have been trying to export some mailbox statistics to Excel with

. This is the script I came up with, but now I'm at a dead end:

Get-Mailbox |
select DisplayName, Alias, Database, TotalItemSize, ItemCount,
StorageLimitStatus, IssueWarningQuota, ProhibitSendQuota |
Export-Csv c:\xyz.csv

The problem I'm having is that it exports everything except
into the .csv file. I don't know what the issue is.

Answer Source

The object that Get-Mailbox returns doesn't not contain the property's you are trying to select. If you run the following command you will see a list of all properties available that Get-Mailbox can return.

Get-Mailbox | Get-Member -MemberType Properties

You will want to use Get-MailboxStatistics to get those properties:

Get-Mailbox "Your.Mailbox" | Get-MailboxStatistics |
    Select TotalItemSize, ItemCount, StorageLimitStatus

To get all the properties into the csv file you could create a custom object and export that:

Get-mailbox "Your.Mailbox" | %{
    $mb = $_
    $stats = $mb | Get-MailboxStatistics | Select TotalItemSize,ItemCount,StorageLimitStatus

    $Properties = @{ 
          DisplayName = $mb.DisplayName 
          Alias = $mb.Alias
          Database = $mb.Database
          IssueWarningQuota = $mb.IssueWarningQuota

    New-Object psobject -Property $properties
} | Export-Csv c:\xyz.csv
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download