Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exchange Power Shell Command

Posted on 2013-05-22
30
Medium Priority
?
1,160 Views
Last Modified: 2013-05-28
Hello Guys,

Can anyone help out to get me command for seeing Storage Limit Size of all mailboxes in exchange.


Thanks
0
Comment
Question by:msretailit
  • 11
  • 10
  • 6
  • +1
30 Comments
 
LVL 33

Expert Comment

by:Busbar
ID: 39186697
get-mailbox | fl name,*quota*
or
get-mailbox | ft name,*quota*
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39186698
from http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2009/08/30/mailbox-users-storage-limit.aspx
Get-WMIObject Exchange_Mailbox -Namespace root\MicrosoftExchangeV2 -Computer $server -Filter * | Foreach-Object { 

   $IncludedProperties = "mDBUseDefaults","mDBStorageQuota","mDBOverQuotaLimit","mDBOverHardQuotaLimit" 
   $user = Get-QADUser $_.LegacyDN -IncludedProperties $IncludedProperties 

   if(!$user.mDBUseDefaults) 
   { 
     Add-member -InputObject $_ NoteProperty mDBUseDefaults $user.mDBUseDefaults 
     Add-member -InputObject $_ NoteProperty mDBStorageQuota $user.mDBStorageQuota 
     Add-member -InputObject $_ NoteProperty mDBOverQuotaLimit $user.mDBOverQuotaLimit 
     Add-member -InputObject $_ NoteProperty mDBOverHardQuotaLimit $user.mDBOverHardQuotaLimit –PassThru 
   }  

} | Select-Object MailboxDisplayName,Size,mDBUseDefaults,mDBStorageQuota,mDBOverQuotaLimit,mDBOverHardQuotaLimit

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
ID: 39186722
You may need to consider the users who are set to use database  limits. Check out this article.

http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/06/use-powershell-to-manage-exchange-server-mailbox-storage-limits.aspx
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:msretailit
ID: 39186731
Hello busbar,

Can you please let me know how can i export it into CSV with all colums.
0
 
LVL 33

Expert Comment

by:Busbar
ID: 39186733
get-mailbox | select-object name,*quota* | Export-csv c:\mailboxreporting.csv
0
 

Author Comment

by:msretailit
ID: 39186736
That was so easy command to run

Thanks Busbar
0
 
LVL 33

Expert Comment

by:Busbar
ID: 39186741
you are welcome anytime.
0
 

Author Comment

by:msretailit
ID: 39186746
I think something is wrong , Default Limit are also showing unlimited Limits.

Can you please try Busbar
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39186903
@ msretailit, Did you check my post?
0
 

Author Comment

by:msretailit
ID: 39186955
Hello Subsun,


I have tried below command


Get-Mailbox | Select-Object DisplayName,Database,IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota | Sort-Object DisplayName | Export-Csv –Path .\MailboxLimits.csv –NoTypeInformation

But still its showing unlimited mailbox size for the users who have default mailbox size.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39187047
As I mentioned in my previous post, you might need to check the database limits if user is set to use it. You can refer the article which explains the same..
0
 

Author Comment

by:msretailit
ID: 39187100
Hello Subsun,

Yes our users are having database limits but few of them have unlimited size.

So for me its hard to identify which users actual have unlimited and which users have default limit.


By the article i understand that is explains me  how can i manage the mailbox database sizes.

I want to see which users have default mailbox size and which users have unlimited mailbox size.
0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 2000 total points
ID: 39189507
Ok.. try this script and see if you get the desired results..
$result = @()
Foreach ($user in (Get-Mailbox -ResultSize Unlimited)){
		If ($user.UseDatabaseQuotaDefaults -eq $true)
  {
	$ProhibitSendReceiveQuota = (Get-MailboxDatabase $user.Database).ProhibitSendReceiveQuota.Value
	$ProhibitSendQuota = (Get-MailboxDatabase $user.Database).ProhibitSendReceiveQuota.Value
	$IssueWarningQuota = (Get-MailboxDatabase $user.Database).IssueWarningQuota.Value
  }
  Else{
  $ProhibitSendReceiveQuota = $user.ProhibitSendReceiveQuota
  $ProhibitSendQuota = $user.ProhibitSendQuota
  $IssueWarningQuota = $user.IssueWarningQuota.Value
		
  If ($ProhibitSendReceiveQuota.IsUnlimited -eq $true -or $ProhibitSendReceiveQuota.Value -eq $null)
    {$ProhibitSendReceiveQuota = "Unlimited"}
  Else {$ProhibitSendReceiveQuota = $ProhibitSendReceiveQuota.Value}

  If ($ProhibitSendQuota.IsUnlimited -eq $true -or $ProhibitSendQuota.Value -eq $null)
    {$ProhibitSendQuota = "Unlimited"}
  Else {$ProhibitSendQuota = $ProhibitSendQuota.Value}

		}
$result += $user | Select-Object DisplayName,Database,@{N="IssueWarningQuota";E={$IssueWarningQuota}},@{N="ProhibitSendQuota";E={$ProhibitSendQuota}},@{N="ProhibitSendReceiveQuota";E={$ProhibitSendReceiveQuota}}
}
$result | Export-Csv c:\Report.csv -NoTypeInformation

Open in new window

0
 
LVL 33

Expert Comment

by:Busbar
ID: 39189849
All of that was done in a single line

(Edit: Off-topic comments removed. Modulus_Twelve.)
0
 

Author Comment

by:msretailit
ID: 39189947
Hello Subsun,

Got Following Error



"Bad numeric constant: 12..
At line:1 char:4
+ 12. <<<< PS1
    + CategoryInfo          : ParserError: (12.:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : BadNumericConstant"
0
 
LVL 33

Expert Comment

by:Busbar
ID: 39189956
he is trying to convince you with a script that you couldn't utilize for 2 days and I solved that with a simple and single line in 15 minutes.

(Edit: Off-topic comments removed. Modulus_Twelve.)
0
 

Author Comment

by:msretailit
ID: 39189964
Hello Busbar,

Yes i got what i need but i let you know about the issue of the results that is its showing default mailbox size as unlimited.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39189997
@Busbar, I am not trying to convince but trying give a working solution. It's true that get-mailbox will give the quota details of mailbox but the result will be incorrect if the mailbox is set to UseDatabaseQuotaDefaults $true.

For example If mailbox is set to UseDatabaseQuotaDefaults $true and the database has a limit of 200 MB. The get-mailbox command still shows the result as Unlimited (or what ever values it was set to) which is not the actual limit of the mailbox.

@msretailit, I didn't test the script, I will check it as soon as I get a chance.
0
 
LVL 33

Expert Comment

by:Busbar
ID: 39190030
BTW I didn't note that msretailit has issues with the default sizes.

This could be simple addressed by selecting UseDatabaseQuotaDefaults , then the command would be

get-mailbox | select-object name,*quota*, UseDatabaseQuotaDefaults | Export-csv c:\mailboxreporting.csv

that will highlight the users with the default quota applied.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39190043
That still wont give the actual limit in result file. Again we need to check what is the limit set on the database to find the actual limit. it's a pain if there is different limit set for different databases.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39190074
@msretailit, I just tried the script it didn't give me any error.. Also I don't have any line in the script 12. PS1. Can you tell me how you are running the script?

You can either copy the code to a text file and save it as .ps1 file (report.ps1) and run it from EMS.

[PS] C:\>.\report.ps1

Or just copy paste the code to EMS and press enter..
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39190390
My suggestion is to reopen the question as the  current solution is incomplete and award points once the solution is finalized..
0
 

Author Comment

by:msretailit
ID: 39190505
Hello Admin,


From Busban answer i got what i need but then i re-verified it then i was having problem with unlimited\ default mailbox size.

As i am new to expertexchange, I am not sure how we can reopen this question.


Subsun :- Command is working may be i did mistake for before.

Is it possible if we can add "UseDatabaseQuotaDefaults" on the script which you given.

As it will be more beneficial if see we if they are using Database Default Quota.
0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 2000 total points
ID: 39190547
Yes you can..

Change the line 23 to

$result += $user | Select-Object DisplayName,Database,UseDatabaseQuotaDefaults,@{N="IssueWarningQuota";E={$IssueWarningQuota}},@{N="ProhibitSendQuota";E={$ProhibitSendQuota}},@{N="ProhibitSendReceiveQuota";E={$ProhibitSendReceiveQuota}}

Open in new window

0
 

Author Comment

by:msretailit
ID: 39191052
Hello Subsun,

Thanks alot thats perfect,

Is it possible if we can add actual mailbox size used in the report.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39191112
Yes you can, PowerShell is very flexible..

Change the line 23 to
$result += $user | Select-Object DisplayName,Database,UseDatabaseQuotaDefaults,@{N="TotalItemSize";E={(Get-MailboxStatistics $_).TotalItemSize}},@{N="IssueWarningQuota";E={$IssueWarningQuota}},@{N="ProhibitSendQuota";E={$ProhibitSendQuota}},@{N="ProhibitSendReceiveQuota";E={$ProhibitSendReceiveQuota}}

Open in new window

0
 

Author Comment

by:msretailit
ID: 39197319
Thanks Subsun,

Admin :- Subsun given me perfect answer, You can give points to Subsun.
0
 

Author Comment

by:msretailit
ID: 39203655
Thanks Subsun
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

927 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