Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Exchange Power Shell

Posted on 2010-08-19
9
Medium Priority
?
859 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
Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

 

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
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…

648 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