Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

Powershell for Exchange 2007

Get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName SERVER1 | select-object MailboxDisplayName,TotalItems,Size | sort
-descending “Size” | select-object -first 25 | ConvertTo-html -title
“Top 25 Largest Mailboxes on SERVER1” > “D:\Stats\25 Largest Mailboxes.html”


I want to run a powershell to list out the top 25 mailboxes but it fails. What;s the Namespace should I use ? Is "ROOT\MicrosoftExcahngev2" is the same for every server ?

Tkx
Avatar of Manpreet SIngh Khatra
Manpreet SIngh Khatra
Flag of India image

Get-Mailbox | Get-MailboxStatistics | select-object MailboxDisplayName,TotalItems,Size | Sort -descending “Size” | select-object -first 25 > “D:\Stats\25 Largest Mailboxes.csv"

- Racny
TotalItemSize its one word :)
DisplayName instead of MailboxDisplayName

Me trying to work on it in my lab to try and see if i can get the data

- Rancy
SOLUTION
Avatar of Manpreet SIngh Khatra
Manpreet SIngh Khatra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DCVATech
DCVATech

Try the following:

Get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -Computer  SERVER1 | select-object MailboxDisplayName,TotalItems,Size | sort
-descending “Size” | select-object -first 25 | ConvertTo-html -title
“Top 25 Largest Mailboxes on SERVER1” > “D:\Stats\25 Largest Mailboxes.html”

-Computername=-Computer

This should work. Yes, "ROOT\MicrosoftExcahngev2"  is same for all servers.
Avatar of AXISHK

ASKER

TotalItems and Size return with blank value. I run on my Exchange mailbox role. Any idea ?

Tkx
If using Get-MailboxStatistics command, try replacing TotalItemSize (in select-object section) with this:

@{label=”TotalItemSize(MB)”;e={$_.TotalItemSize.Value.ToMB()}}
Avatar of AXISHK

ASKER

Still no hope...

[PS] C:\Documents and Settings\adm_sl>Get-Mailbox | Get-MailboxStatistics |
select-object MailboxDisplayName,@{label="TotalItemSize(MB)";e={$_.TotalItemSize
.Value.ToMB()}} ,Size | Sort -descending "Size" | select-object -first 25 > "E:\
25 Largest Mailboxes.csv"
Select-Object : Illegal key label
At line:1 char:52
+ Get-Mailbox | Get-MailboxStatistics | select-object  <<<< MailboxDisplayName,
@{label="TotalItemSize(MB)";e={$_.TotalItemSize.Value.ToMB()}} ,Size | Sort -de
scending "Size" | select-object -first 25 > "E:\25 Largest Mailboxes.csv"
Don't use MailboxDisplayName. It should be DisplayName, as self-corrected by Rancy.
Also don't use Size.
In the next section, use
 |sort -descending "TotalItemSize(MB)" |

So the new command (with some additional minor changes) becomes:

Get-Mailbox | Get-MailboxStatistics |
select DisplayName, @{n="TotalItemSize(MB)";e={$_.TotalItemSize.Value.ToMB()}} |Sort -descending "TotalItemSize(MB)" | select-object -first 25 |ft -auto >
 "E:\25 Largest Mailboxes.csv"
Avatar of AXISHK

ASKER

It doesn't return any result with the screen state as below. Any idea ?


[PS] C:\Documents and Settings\adm_sl>Get-Mailbox | Get-MailboxStatistics |
>> select DisplayName, @{n="TotalItemSize(MB)";e={$_.TotalItemSize.Value.ToMB()}
} |Sort -descending "TotalItemSize(MB)" | select-object -first 25 |ft -auto >
>>  "E:\25 Largest Mailboxes.csv"
>>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial