• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

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

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
itguy565
Asked:
itguy565
  • 3
  • 2
1 Solution
 
SubsunCommented:
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
 
itguy565Author Commented:
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
 
itguy565Author Commented:
One more question if you will still help:

How do I export this to CSV?
0
 
itguy565Author Commented:
NM,I will open another question for that :p Thanks.
0
 
SubsunCommented:
Use Select-Object instead of FT and pipe the output to Export-CSV..
0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now