Solved

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

Posted on 2013-02-05
5
429 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
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
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…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
how to add IIS SMTP to handle application/Scanner relays into office 365.

680 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