Get-IEXDatabaseQuotaStatistics


posted by ps1
09-23-2009

Downloads: 381
File size: 3.1kB
Views: 1,174

Embed
Get-IEXDatabaseQuotaStatistics
  1. ## ===================================================================== 
  2. ## Title       : Get-IEXDatabaseQuotaStatistics 
  3. ## Description : Retrieve all User Mailboxes that have custom Database Quota values and extend the results with custom properties 
  4. ## Author      : Idera 
  5. ## Date        : 09/15/2009 
  6. ## Input       :  No input 
  7. ##    
  8. ## Output      : System.Management.Automation.PSCustomObject  
  9. ## Usage       :  
  10. ##              1.  Gets all User Mailboxes that have custom Database Quota values and extend the results with custom properties  
  11. ##              Get-IEXDatabaseQuotaStatistics 
  12. ##                  
  13. ##                              
  14. ## Notes       : 
  15. ## Tag         : Exchange 2007, mailbox, statistics, get 
  16. ## Change log  :  
  17. ## ===================================================================== 
  18.    
  19. #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin  
  20.  
  21.  
  22. function Get-IEXDatabaseQuotaStatistics 
  23. {  
  24.  
  25.   Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox -Filter {UseDatabaseQuotaDefaults -eq $false} | Foreach-Object{  
  26.  
  27.   trap {  
  28.  
  29.      Write-Error $_  
  30.  
  31.      Continue  
  32.  
  33.   }  
  34.  
  35.  
  36.  
  37.   $Stats = Get-MailboxStatistics $_.Identity  
  38.  
  39.   $mbx = $_ | Select-Object Name,ServerName,Database,MaxSendSize,MaxReceiveSize,UseDatabaseQuotaDefaults,IssueWarningQuota,RulesQuota,ProhibitSendQuota,ProhibitSendReceiveQuota 
  40.   Add-Member -Input $mbx -MemberType NoteProperty -Name MailboxSize -Value $Stats.TotalItemSize 
  41.   Add-Member -Input $mbx -MemberType NoteProperty -Name StorageLimitStatus -Value $Stats.StorageLimitStatus  
  42.  
  43.   $TotalItemSize = $Stats.TotalItemSize  
  44.  
  45.   $IssueWarningQuota = $mbx.IssueWarningQuota 
  46.   $ProhibitSendQuota = $mbx.ProhibitSendQuota 
  47.   $ProhibitSendReceiveQuota = $mbx.ProhibitSendReceiveQuota  
  48.  
  49.    
  50.  
  51.   if($TotalItemSize -gt 0) 
  52.   {  
  53.  
  54.  
  55.    $TotalItemSize = [double]$TotalItemSize  
  56.  
  57.    
  58.  
  59.    if($IssueWarningQuota -AND $IssueWarningQuota -gt 0) 
  60.    {  
  61.  
  62.     $IssueWarningQuota = [double]$IssueWarningQuota.Value.ToBytes()  
  63.  
  64.     Add-Member -Input $mbx -MemberType NoteProperty -Name IssueWarningPercentage -Value ("{0:P2}" -f ($TotalItemSize/$IssueWarningQuota)) 
  65.    
  66.    else 
  67.    
  68.     Add-Member -Input $mbx -MemberType NoteProperty -Name IssueWarningPercentage -Value $null 
  69.    }  
  70.  
  71.    
  72.  
  73.    if($ProhibitSendQuota -AND $ProhibitSendQuota -gt 0) 
  74.    {  
  75.  
  76.     $ProhibitSendQuota = [double]$ProhibitSendQuota.Value.ToBytes()  
  77.  
  78.     Add-Member -Input $mbx -MemberType NoteProperty -Name ProhibitSendPercentage -Value ("{0:P2}" -f ($TotalItemSize/$ProhibitSendQuota)) 
  79.    
  80.    else 
  81.    
  82.     Add-Member -Input $mbx -MemberType NoteProperty -Name ProhibitSendPercentage -Value $null 
  83.    }  
  84.  
  85.    
  86.  
  87.    if($ProhibitSendReceiveQuota -AND $ProhibitSendReceiveQuota -gt 0) 
  88.    {  
  89.  
  90.     $ProhibitSendReceiveQuota = [double]$ProhibitSendReceiveQuota.Value.ToBytes()  
  91.  
  92.     Add-Member -Input $mbx -MemberType NoteProperty -Name ProhibitSendReceivePercentage -Value ("{0:P2}" -f ($TotalItemSize/$ProhibitSendReceiveQuota)) 
  93.    
  94.    else 
  95.    
  96.     Add-Member -Input $mbx -MemberType NoteProperty -Name ProhibitSendReceivePercentage -Value $null 
  97.    }  
  98.  
  99.  
  100.   }  
  101.  
  102.   $mbx 

Retrieve all User Mailboxes that have custom Database Quota values and extend the results with custom properties.

Copyright 2012 PowerShell.com. All rights reserved.