?
Solved

Exchange Power Shell

Posted on 2010-08-19
9
Medium Priority
?
857 Views
Last Modified: 2012-08-14
I'm new to Exchange Power Shell, I found this script and would like to know if its possible to run it on several Exchange servers at the same time or do you have to run it on each one of them one at a time. Also, can you modify the script to add the location and username?

[PS] D:\>Get-MailboxServer R04BYNMSGA1 | Get-MailboxStatistics | where {$_.ObjectClass -eq "Mailbox" -and $_.TotalItemSize -gt 512000kb} |         Sort-Object TotalItemSize -Descending | FT @{label="Database";expression={$_.DatabaseName}},@{label="User";expression={$_.DisplayName}},@{label="Total Size (MB)";expression={$_.TotalItemSize.Value.ToKB()}},@{label="Storage Limit";expression={$_.StorageLimitStatus}} -auto
0
Comment
Question by:vhaperbaugub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 27

Expert Comment

by:shauncroucher
ID: 33474136
Yes, no problem running this on two mailbox servers, open two powershell windows and run side by side. or do one after the other like this:

"server1","server2" | get-mailboxserver | get-mail......

Shaun
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 33474158

You can have pretty much anything you want :)

Location is Office?

Exporting to CSV here, I've never liked the use for Format-Table in that example.

Chris
$Servers = "ExchangeServer1", "ExchangeServer2", "ExchangeServer3", "etc"

$Servers | ForEach-Object {
  Get-MailboxStatistics -Server $_ | 
    Where-Object { $_.ObjectClass -eq "Mailbox" -And $_.TotalItemSize -gr 512Mb }
} | Sort-Object TotalItemSize -Descending |
  Select-Object `
    @{n='Database';e={ $_.DatabaseName }},
    @{n='User';e={ $_.DisplayName }},
    @{n='Total Size (MB)';e={ $_.TotalItemSize.Value.ToMb() }},
    @{n='Storage Limit';e={ $_.StorageLimitStatus }},
    @{n='Username';e={ (Get-User $_.LegacyExchangeDN).SamAccountName }},
    @{n='Office';e={ (Get-User $_.LegacyExchangeDN).Office }} |
  Export-Csv "OutputFile.csv" -NoTypeInformation

Open in new window

0
 
LVL 12

Expert Comment

by:Mahmoud Sabry
ID: 33474801
just replace "Get-MailboxServer R04BYNMSGA1"

by

Get-Mailbox

this will give u the results for all mailboxes in the organization

and for the output

use  | FT database, displayname,....... etc all separated by commaa
for example
get-mailbox | get-mailboxstatistics | ft database, displayname,totalitemsize

but first to get relaiable result before running the command, adjust the window dimensions from shell properties

and u can use the command start-transcript c:\usersquota.txt

this will put the result in the specified text file, copy the rusult to Excel file, there u can divide quota in byte by 1024*1024 to translate it to MB
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vhaperbaugub
ID: 33475217
Chris-Dent - The script you provided won't run in PS, I copied and pasted into PS and got this:

[PS] C:\>$Servers = "r04bynmsga1", "r04bynmsga2"
[PS] C:\>
[PS] C:\>$Servers | ForEach-Object {
>>   Get-MailboxStatistics -Server $_ |
>>     Where-Object { $_.ObjectClass -eq "Mailbox" -And $_.TotalItemSize -gr 512
Mb }
>> } | Sort-Object TotalItemSize -Descending |
>>   Select-Object `
>>     @{n='Database';e={ $_.DatabaseName }},
>>     @{n='User';e={ $_.DisplayName }},
>>     @{n='Total Size (MB)';e={ $_.TotalItemSize.Value.ToMb() }},
>>     @{n='Storage Limit';e={ $_.StorageLimitStatus }},
>>     @{n='Username';e={ (Get-User $_.LegacyExchangeDN).SamAccountName }},
>>     @{n='Office';e={ (Get-User $_.LegacyExchangeDN).Office }} |
>>   Export-Csv "OutputFile.csv" -NoTypeInformation
>>
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 33475264

There's an error (fixed here), but you need to press return again to finish it off.

Chris
$Servers | ForEach-Object {
  Get-MailboxStatistics -Server $_ | 
    Where-Object { $_.ObjectClass -eq "Mailbox" -And $_.TotalItemSize -gt 512Mb }
} | Sort-Object TotalItemSize -Descending |
  Select-Object `
    @{n='Database';e={ $_.DatabaseName }},
    @{n='User';e={ $_.DisplayName }},
    @{n='Total Size (MB)';e={ $_.TotalItemSize.Value.ToMb() }},
    @{n='Storage Limit';e={ $_.StorageLimitStatus }},
    @{n='Username';e={ (Get-User $_.LegacyExchangeDN).SamAccountName }},
    @{n='Office';e={ (Get-User $_.LegacyExchangeDN).Office }} |
  Export-Csv "OutputFile.csv" -NoTypeInformation

Open in new window

0
 

Author Comment

by:vhaperbaugub
ID: 33475417
Does this script run against all the Exchange servers or is their a way to add them to the script?
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 33476635

You'd be better with one of msabry06's changes if you want everything.

In context with the bits to get user information...

Chris
Get-Mailbox |
  Get-MailboxStatistics |
  Where-Object { $_.ObjectClass -eq "Mailbox" -And $_.TotalItemSize -gt 512Mb } |
  Sort-Object TotalItemSize -Descending |
  Select-Object `
    @{n='Database';e={ $_.DatabaseName }},
    @{n='User';e={ $_.DisplayName }},
    @{n='Total Size (MB)';e={ $_.TotalItemSize.Value.ToMb() }},
    @{n='Storage Limit';e={ $_.StorageLimitStatus }},
    @{n='Username';e={ (Get-User $_.LegacyExchangeDN).SamAccountName }},
    @{n='Office';e={ (Get-User $_.LegacyExchangeDN).Office }} |
  Export-Csv "OutputFile.csv" -NoTypeInformation

Open in new window

0
 

Author Comment

by:vhaperbaugub
ID: 33504169
Does anyone know of a good site to use for Exchange Power Shell example scripts?
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 33504573

I don't, but if you were to learn the basics of PowerShell you'd be able to make your own with very very few limitations.

http://powershell.com/Mastering-PowerShell.pdf

In the example I pasted above only the CmdLets make it Exchange specific, and Get-Help will tell you all you need to know about those (e.g. Get-Help Get-Mailbox -Full | more).

Chris
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

764 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