Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Export Powershell Code to CSV

Posted on 2013-02-05
4
Medium Priority
?
563 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

618 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