Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1220
  • Last Modified:

Exchange 2010 Output Powershell Command to CSV

I am unable to use the below script and export a usable CSV file.

Get-Mailbox UserAlias | Get-MailboxFolderStatistics | Where {$_.ItemsInFolder -gt 1} | Sort-Object -Property ItemsInFolder -Descending | fl Identity, ItemsInFolder | export-csv c:\transfer\exchangeuserstats.csv

If I remove  '| export-csv c:\transfer\exchangeuserstats.csv' it outputs to the screen fine.

The export to CSV likes like the below.

#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.ListViewHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,

How would I use the above command and export a CSV file that lists the folders and ItemsinFolder ?

FYI - Output to screen is typical to the below.
Identity : xxx.lan/Active Users/Hartford/Hartford Users/User Name\Sent Items
ItemsInFolder : 7

Thanks for your assistance.
0
fmauri
Asked:
fmauri
1 Solution
 
LindySCommented:
Try the command like this instead;

Get-Mailbox UserAlias | Get-MailboxFolderStatistics | Where {$_.ItemsInFolder -gt 1} | Sort-Object -Property ItemsInFolder -Descending | Select Identity, ItemsInFolder | export-csv c:\transfer\exchangeuserstats.csv -notype
0
 
d3ath5tarCommented:
0
 
SieQCommented:
LindyS is right,
use select instead of format-list
select Identity, ItemsInFolder - NOT fl Identity, ItemsInFolder
0
 
fmauriAuthor Commented:
Worked perfect, thanks for the quick and accurate response.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Tackle projects and never again get stuck behind a technical roadblock.
Join Now