?
Solved

Powershell Script to list email accounts on specific server based on company

Posted on 2013-02-05
5
Medium Priority
?
433 Views
Last Modified: 2013-02-05
Ladies and Gents,

I need assistance modifying the following script:


Get-Mailbox -Server "server1"| Get-MailboxStatistics| where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto

Open in new window


I need this script to display all the following:

Company, User, Total Size of Mailbox in GB and in MB

Items to be excluded are (ITEMS and Storage LIMITS) ADD (Company and SIZE in GB)
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
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 38855777
Try..
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()}} -auto

Open in new window

0
 
LVL 11

Author Comment

by:itguy565
ID: 38855842
The Code was perfect other than one modification that i made. The final code was as follows.

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

Open in new window


I wanted two columns one for GB and one for MB.


Thanks again for your quick response!
0
 
LVL 11

Author Comment

by:itguy565
ID: 38855905
One more question if you will still help:

How do I export this to CSV?
0
 
LVL 11

Author Comment

by:itguy565
ID: 38855909
NM,I will open another question for that :p Thanks.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38855932
Use Select-Object instead of FT and pipe the output to Export-CSV..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 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