Solved

Export Powershell Code to CSV

Posted on 2013-02-05
4
511 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
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…
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)

707 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

15 Experts available now in Live!

Get 1:1 Help Now