Solved

Exchange 2010 Output Powershell Command to CSV

Posted on 2012-03-14
4
1,158 Views
Last Modified: 2012-03-14
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
Comment
Question by:fmauri
4 Comments
 
LVL 3

Accepted Solution

by:
LindyS earned 500 total points
ID: 37720272
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
 
LVL 7

Expert Comment

by:d3ath5tar
ID: 37720490
0
 
LVL 2

Expert Comment

by:SieQ
ID: 37720570
LindyS is right,
use select instead of format-list
select Identity, ItemsInFolder - NOT fl Identity, ItemsInFolder
0
 

Author Closing Comment

by:fmauri
ID: 37721102
Worked perfect, thanks for the quick and accurate response.
0

Featured Post

Does Powershell have you tied up in knots?

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now