header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Mailboxstatistics
Last Post 24 Jul 2008 04:22 PM by hbkrules69. 15 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
hbkrules69User is Offline
New Member
New Member
Posts:2

--
28 Jun 2008 04:36 PM  

Hello,

I am wondering if there is any way to output the mailboxstats of all users on a mail server by either username or Alias. I have been doing it by displayname, which is fine, but when I run the displayname against an A/D query to see which account is disabled/enabled, my output of names is longer than what I originally started with. This is because we always have employees that leave the company as employees and come back as contractors, and they get a new A/D account where the display name is usually the same. Any assistance is very much appreciated

My Code

Get-mailboxserver -id: |get-mailboxstatistics|fl displayname, itemCount

 

Get-mailboxserver -id: |get-mailboxstatistics|fl , itemCount

This code provides a blank continous column under Alias

Thanks..

ziemborUser is Offline
New Member
New Member
Posts:7

--
28 Jun 2008 06:08 PM  

try

get-Mailbox| get-MailboxStatistics

 

khikoUser is Offline
New Member
New Member
Posts:12

--
30 Jun 2008 01:59 AM  
yap get-mailboxstatistics works. here is what i used, it also give me the output in MB if you are after the sizes of mailboxes

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,StorageLimitStatus,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount
ckemppelUser is Offline
New Member
New Member
Posts:5

--
23 Jul 2008 02:29 PM  
This code worked for what I was looking for as well (thanks!) except I also need to include Alias,Database & SMTP address in the output. When I format as below, the output does include Database, but leaves Alias and SMTP blank

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft Alias,Database,*SMTP*,DisplayName,StorageLimitStatus,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Any ideas?
marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:181

--
23 Jul 2008 02:49 PM  
Posted By ckemppel on 07/23/2008 6:29 AM
This code worked for what I was looking for as well (thanks!) except I also need to include Alias,Database & SMTP address in the output. When I format as below, the output does include Database, but leaves Alias and SMTP blank

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft Alias,Database,*SMTP*,DisplayName,StorageLimitStatus,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Any ideas?

 

get-mailboxstatistics doesn't have any such members:

get-mailboxstatistics|get-member *smtp*,*alias* <--returns nothing

ckemppelUser is Offline
New Member
New Member
Posts:5

--
23 Jul 2008 02:58 PM  
Thanks Marco, that explains why the output is blank ;)

Get-Mailbox | Format-Table Alias,*SMTP* outputs the alias & SMTP so is there a way to string both commands together to get the desired output I need into a single CSV file?
marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:181

--
23 Jul 2008 03:09 PM  
Posted By ckemppel on 07/23/2008 6:58 AM
Thanks Marco, that explains why the output is blank ;)

Get-Mailbox | Format-Table Alias,*SMTP* outputs the alias & SMTP so is there a way to string both commands together to get the desired output I need into a single CSV file?

 

Maybe there's a better way, but this should work:

[PS] >get-mailbox|ft alias,@{l="database";e={$_|get-mailboxstatistics|select database}}

Now, that could make a very long command to add everything you're looking for...

ckemppelUser is Offline
New Member
New Member
Posts:5

--
23 Jul 2008 03:39 PM  
Thanks Marco, I will continue trying varients to see if I can get the desired output.
ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
23 Jul 2008 06:20 PM  

 

Piping to select will wrap the database coulmn in array, it shows like:

alias   database
------    -------------
user   @{...}

 

Try this:

PS > get-mailbox | ft alias, @{l="database";e={ (get-mailboxstatistics $_).database}}

ckemppelUser is Offline
New Member
New Member
Posts:5

--
23 Jul 2008 07:34 PM  

I was able to get the output I was desiring with the following:

get-mailbox -Server "MYE2K7SERVERNAME" | ft alias, *SMTP*, @{l="Database";e={ (get-mailboxstatistics $_).database}}, @{l="DisplayName";e={ (get-mailboxstatistics $_).Displayname}}, @{l="StorageLimitStatus";e={ (get-mailboxstatistics $_).StorageLimitStatus}},@{l="ItemCount";e={ (get-mailboxstatistics $_).ItemCount}},@{l="TotalItemSize(MB)";e={ (get-mailboxstatistics $_).TotalItemSize.Value.ToMB()}} >f:\mailbox_exports\E2007Mailboxes.csv

However, I've got a couple of challenges yet to figure out:
1. The output is compressing the longer value columns with ellipses {...} in the output file:


Alias PrimarySmtp Database DisplayNam StorageLim ItemCount TotalItemS
Address e itStatus ize(MB)
----- ----------- -------- ---------- ---------- --------- ----------
LOGONID Allan.Us... SERVERNA... UserN, ... BelowLimit 1202 54

How can I format it to output the complete contents of the field?

2. Is there an easy way to name the export file with a date stamp?

Thanks for everyone's help!

ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
23 Jul 2008 09:38 PM  

I would go this way:

1. You have to many get-mailboxstatistics calls, you can use one call per user.
2. Use select-object instead of format-table and then pipe to export-csv
3. If you need to export output to csv don't use any format-* at the end of the pipeline, let powershell deserialize the output for you.

 

$Database = @{n="Database";e={ $stats.database }}
$DisplayName = @{n="DisplayName";e={ $stats.Displayname }}
$StorageLimitStatus = @{n="StorageLimitStatus";e={ $stats.StorageLimitStatus }}
$ItemCount = @{n="ItemCount";e={ $stats.ItemCount }}
$TotalItemSize = @{n="TotalItemSize(MB)";e={ $stats.TotalItemSize.Value.ToMB() }}

get-mailbox -server "MYE2K7SERVERNAME" | foreach {
 $stats = get-mailboxstatistics $_
 $_ | select alias, *SMTP*,$Database,$DisplayName,$StorageLimitStatus,$ItemCount,$TotalItemSize
} | export-csv f:\mailbox_exports\E2007Mailboxes.csv -nti

 

 

 

ckemppelUser is Offline
New Member
New Member
Posts:5

--
24 Jul 2008 02:41 AM  
Thanks Shay, that did the trick and was much more efficient (although for whatever reason I had to use the full -NoTypeInformation instead of -nti in the syntax). Any thoughts on how to have it save the export w/the current date in the export file name?
ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
24 Jul 2008 07:42 AM  
Sorry, -nti is available in CTP2, you can use -not in v1.

How about embedding the date in the file name:

..."E2007Mailboxes_$(get-date -f MM_dd_yyyy).csv" -not
bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
24 Jul 2008 01:18 PM  
I prefer -NoType. I think it is clearer in intent.
ShayUser is Offline
Basic Member
Basic Member
Posts:228

--
24 Jul 2008 02:27 PM  
No doubt :)
hbkrules69User is Offline
New Member
New Member
Posts:2

--
24 Jul 2008 04:22 PM  
thanks for the responses
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer