Solved

Export Powershell Code to CSV

Posted on 2013-02-05
4
539 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
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
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
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

839 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