Exchange Power Shell Command

Hello Guys,

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


Thanks
msretailitAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
SubsunConnect With a Mentor Commented:
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
 
BusbarSolutions ArchitectCommented:
get-mailbox | fl name,*quota*
or
get-mailbox | ft name,*quota*
0
 
Meir RivkinFull stack Software EngineerCommented:
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
SubsunCommented:
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
 
msretailitAuthor Commented:
Hello busbar,

Can you please let me know how can i export it into CSV with all colums.
0
 
BusbarSolutions ArchitectCommented:
get-mailbox | select-object name,*quota* | Export-csv c:\mailboxreporting.csv
0
 
msretailitAuthor Commented:
That was so easy command to run

Thanks Busbar
0
 
BusbarSolutions ArchitectCommented:
you are welcome anytime.
0
 
msretailitAuthor Commented:
I think something is wrong , Default Limit are also showing unlimited Limits.

Can you please try Busbar
0
 
SubsunCommented:
@ msretailit, Did you check my post?
0
 
msretailitAuthor Commented:
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
 
SubsunCommented:
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
 
msretailitAuthor Commented:
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
 
SubsunConnect With a Mentor Commented:
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
 
BusbarSolutions ArchitectCommented:
All of that was done in a single line

(Edit: Off-topic comments removed. Modulus_Twelve.)
0
 
msretailitAuthor Commented:
Hello Subsun,

Got Following Error



"Bad numeric constant: 12..
At line:1 char:4
+ 12. <<<< PS1
    + CategoryInfo          : ParserError: (12.:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : BadNumericConstant"
0
 
BusbarSolutions ArchitectCommented:
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
 
msretailitAuthor Commented:
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
 
SubsunCommented:
@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
 
BusbarSolutions ArchitectCommented:
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
 
SubsunCommented:
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
 
SubsunCommented:
@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
 
SubsunCommented:
My suggestion is to reopen the question as the  current solution is incomplete and award points once the solution is finalized..
0
 
msretailitAuthor Commented:
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
 
SubsunConnect With a Mentor Commented:
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
 
msretailitAuthor Commented:
Hello Subsun,

Thanks alot thats perfect,

Is it possible if we can add actual mailbox size used in the report.
0
 
msretailitAuthor Commented:
Thanks Subsun,

Admin :- Subsun given me perfect answer, You can give points to Subsun.
0
 
msretailitAuthor Commented:
Thanks Subsun
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.