Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
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…

705 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

14 Experts available now in Live!

Get 1:1 Help Now