Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Currently I'm using this powershell command on the server in the Exchange Management Shell:

Get-MailboxStatistics username | 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

My ultimite goal is to be able to run this from my desktop to query the server remotely. I would also be helpful to be able to query for more then one user (but not all users) and it would also be great if the script could pull the default quota size for the DB that the mailbox sits on.

Right now I have to log into the server, run the Exchange Management Shell and then cut and paste the code. It takes just as long to go into the GUI :-(

my results look like this:

User                    Total Size (MB) Items Storage Limit

Lastname, First(Domain)              10   992    BelowLimit

I'd like it to look like this:

User                    Total Size (MB) Items Storage Limit  Default Limit

Lastname, First(Domain)              10   992    BelowLimit           80MB
Lastname, First(Domain)              15   165         100MB           80MB
share|improve this question

1 Answer 1

Instead of installing the Exchange tools on your local machine, the easiest solution would be to put your code into a Powershell script, save it to the server, and then run the script. Once you have this in place, you can schedule to script to run and email you reports if you choose.

If you really want to run the script remotely, you will need to install Powershell and the Microsoft Exchange Management Tools on your local workstation. The 32-bit Management Tools for all three service packs can be downloaded from this webpage, and this KB article has instructions for installing them. If you are running a 64-bit OS on your workstation, you will need to install the management tools from the Exchange DVD.

Note: Exchange 2007 SP1 and SP2 management tools are not compatible with Windows 7. You will need to be running Exchange 2007 SP3 in order to install the tools.

You can easily modify your script to show multiple users by removing the username parameter from the script. This will display all users in your Exchange environment. The Get-MailboxStatistics command has other options for viewing mailbox statistics by server and database as well, and you can get information on how to run the command with those parameters by entering "get-help get-mailboxstatistics" in the Exchange Management Console.

share|improve this answer
    
Thanks. But how do I save the powershell script to use exchange managment shell? It won't run from regular powershell, it must be run from the exchange management shell as get-mailboxstatistics is not available in the regular powershell on the server. –  MathewC Dec 1 '11 at 20:39
    
There are at least two IDEs for coding Powershell: Powershell ISE (made by Microsoft, comes with Powershell 2.0) PowerGUI Script Editor (made by Quest, comes as part of the PowerGUI software package) There are probably more, but these are the two that I am familiar with. You can also use Notepad and save the file as a .PS1 file (PS1 is the extension for powershell scripts). There is a wealth of resources on Powershell scripting, and they aren't hard to find online. –  smassey Dec 1 '11 at 21:30
2  
You can add Add-PSSnapin -name Microsoft.Exchange.Management.PowerShell.Admin to your powershell profile to access the Exchange cmdlets from a regular session. I would recommend googling "Edit Powershell Profile" to get more information on how to do that. –  smassey Dec 1 '11 at 21:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.