Hi all<\/p>\n
I’m trying to find a viable method to export a CSV report from Exchange 2010 PowerShell, but unable to find a way to get all the fields I want in a single report, hoping someone might be able to help me out with this.<\/p>\n
I’m essentially looking to get a report with the following colums:<\/p>\n
Display Name, Primary Smtp Address, Any Alias Addresses, Item Count, Total Item Size. All in descending order of Total Item Size.<\/p>\n
I’ve found methods to extract portions of each but not all in one document.<\/p>\n
For example:<\/p>\n
Like this I can get everything I need except the Primary Address and Aliases<\/p>\n
Get-MailboxStatistics -Database \"Mailbox Database 1\" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | Export-CSV C:\\MBSizes.csv\n<\/code><\/pre>\nAnd like this I can get the Primary Address and Aliases<\/p>\n
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\\exportsmtp.csv -NoTypeInformation\n<\/code><\/pre>\nBut I can’t find a way to get all the fields I’m looking for into one report.<\/p>\n
Thanks in advance
<\/p>","upvoteCount":3,"answerCount":5,"datePublished":"2017-11-10T09:21:57.000Z","author":{"@type":"Person","name":"joeledwards","url":"https://community.spiceworks.com/u/joeledwards"},"acceptedAnswer":{"@type":"Answer","text":"
Try this do not forget to mark answers as best answer<\/p>\n
$outtbl = @()\n$users = Get-Mailbox -ResultSize Unlimited | Where-Object {$_.UseDatabaseQuotaDefaults -eq $false} \n$users | % {\n $x = Get-MailboxStatistics $_ \n $t = New-Object PSObject -Property @{\n DisplayName= $_.Name\n Emailaddress= $_.PrimarySmtpAddress\n ItemCount= $x.ItemCount\n Alias= $_.alias\n ADsmtp= $_.EmailAddresses -join '.'\n TotalItemSizeMB=$x.totalItemSize.Value.ToMB()\n TotalItemSize= $x.TotalItemSize\n }\n $outtbl += $t\n}\n$outtbl |Sort TotalItemSize -Descending | Export-Csv c:\\report.csv -NoTypeInformation\n\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2017-11-21T22:16:26.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-reports/617781/5","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},"suggestedAnswer":[{"@type":"Answer","text":"Hi all<\/p>\n
I’m trying to find a viable method to export a CSV report from Exchange 2010 PowerShell, but unable to find a way to get all the fields I want in a single report, hoping someone might be able to help me out with this.<\/p>\n
I’m essentially looking to get a report with the following colums:<\/p>\n
Display Name, Primary Smtp Address, Any Alias Addresses, Item Count, Total Item Size. All in descending order of Total Item Size.<\/p>\n
I’ve found methods to extract portions of each but not all in one document.<\/p>\n
For example:<\/p>\n
Like this I can get everything I need except the Primary Address and Aliases<\/p>\n
Get-MailboxStatistics -Database \"Mailbox Database 1\" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | Export-CSV C:\\MBSizes.csv\n<\/code><\/pre>\nAnd like this I can get the Primary Address and Aliases<\/p>\n
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\\exportsmtp.csv -NoTypeInformation\n<\/code><\/pre>\nBut I can’t find a way to get all the fields I’m looking for into one report.<\/p>\n
Thanks in advance
<\/p>","upvoteCount":3,"datePublished":"2017-11-10T09:21:57.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-reports/617781/1","author":{"@type":"Person","name":"joeledwards","url":"https://community.spiceworks.com/u/joeledwards"}},{"@type":"Answer","text":"
Hi,<\/strong><\/p>\nYou can use Either this<\/p>\n
Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, IssueWarningQuota, ProhibitSendQuota, @{label=“TotalItemSize(MB)”;expression={(Get-MailboxStatistics $).TotalItemSize.Value.ToMB()}}, @{label=“ItemCount”;expression={(Get-MailboxStatistics $<\/em>).ItemCount}}, Database | Export-Csv “C:\\Scripts\\UserMailboxSizes.csv” -NoTypeInformation<\/em><\/b><\/p>\nOR<\/p>\n
This Command for above Procedure<\/p>\n
Get-Mailbox -ResultSize Unlimited | Where {$.UseDatabaseQuotaDefaults -eq $false} | Select-Object DisplayName, IssueWarningQuota, ProhibitSendQuota, @{label=“TotalItemSize(MB)”;expression={(Get-MailboxStatistics $<\/em>).TotalItemSize.Value.ToMB()}}, @{label=“ItemCount”;expression={(Get-MailboxStatistics $_).ItemCount}}, Database | Export-Csv “C:\\Scripts\\UserMailboxSizes.csv” -NoTypeInformation<\/em><\/b><\/p>\nuse where to get only the mailboxes that do not use the database default quota.<\/p>\n
Where {$_.UseDatabaseQuotaDefaults -eq $false<\/em><\/b><\/p>\nCheers<\/strong><\/p>\nJay Adams<\/strong><\/p>","upvoteCount":0,"datePublished":"2017-11-10T10:50:41.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-reports/617781/2","author":{"@type":"Person","name":"jayadams7","url":"https://community.spiceworks.com/u/jayadams7"}},{"@type":"Answer","text":"$outtbl = @()\n$users = Get-Mailbox -ResultSize Unlimited | Where-Object {$_.UseDatabaseQuotaDefaults -eq $false} \n$users | % {\n $x = Get-MailboxStatistics $_ \n $t = New-Object PSObject -Property @{\n DisplayName = $_.Name\n Emailaddress = $_.PrimarySmtpAddress\n ItemCount=$x.ItemCount\n TotalItemSizeMB=$x.totalItemSize.Value.ToMB()\n TotalItemSize=$x.TotalItemSize\n }\n $outtbl += $t\n}\n$outtbl |Sort TotalItemSize -Descending | Export-Csv c:\\report.csv -NoTypeInformation\n\n<\/code><\/pre>\nwith this way you can combine to commands looks neat<\/p>","upvoteCount":2,"datePublished":"2017-11-10T14:32:57.000Z","url":"https://community.spiceworks.com/t/exchange-powershell-mailbox-reports/617781/3","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},{"@type":"Answer","text":"