?
Solved

Export Powershell Code to CSV

Posted on 2013-02-05
4
Medium Priority
?
559 Views
Last Modified: 2013-02-05
How do I export this to CSV. Everytime I try i get a blank document:

Get-Mailbox -Server "server1"| Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{L="Company";E={$((Get-Recipient $_.DisplayName).Company)}},@{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (GB)”;expression={$_.TotalItemSize.Value.ToGB()}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}} -auto | Export-Csv mailboxSIZE.csv

Open in new window


it returns a blank document.
0
Comment
Question by:itguy565
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 38855925
Try..
Get-Mailbox -Server "iONSBS2"| Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | Select @{L="Company";E={$((Get-Recipient $_.DisplayName).Company)}},@{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (GB)”;expression={$_.TotalItemSize.Value.ToGB()}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}} -auto | Export-Csv mailboxSIZE.csv

Open in new window

0
 
LVL 11

Author Comment

by:itguy565
ID: 38856003
Error in code:
Error in Code
CSV that was created after auto line removed:
CSV
The output failed. The error in code was at the -auto command. I removed that and was able to get the  csv posted above
0
 
LVL 11

Author Comment

by:itguy565
ID: 38856054
This command completes and runs otherwise ! If you take the pipe to Export-CSV off the end
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38856247
-Auto is a parameter fot FT.. I forgot to remove it.. The code should work fine, if you remove -auto parameter..
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

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
how to add IIS SMTP to handle application/Scanner relays into office 365.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

800 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