Solved

Exchange Power Shell Command

Posted on 2013-05-22
30
1,059 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:sedgwick
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
 

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 500 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 500 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 500 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this video we show how to create a Distribution Group 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 >>…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now