Solved

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

Posted on 2013-02-05
5
431 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 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

Industry Leaders: 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

Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
how to add IIS SMTP to handle application/Scanner relays into office 365.

695 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