Calculate and Set Exchange 2003 Quota's via Powershell
Calling all Exchange/Powershell guru’s. I’ve just joined an organisation that seems to still be working in the dark ages, with regards to some of its technology and their general administrative “Best Practices” (not just within Exchange). I’ve been tasked with helping a colleague tidy up what seems to be an out of control Exchange 2003 server. It currently hosts around 6000 mailboxes, which currently have no quota limits set upon them, either globally or individually. What we are looking to do, is to apply a mailbox policy to all mailbox’s – but before we do this, we need to filter out the mailboxes that will exceed this limit, and apply an individual limit based on their current mailbox size – and this with where I hope you guys can help. What I’m looking for, is a Powershell script that will do the following. - Search an Exchange 2003 server for all mailboxes’s, and report back on size. - Filter mailboxes greater than a specific size, and set appropriate limits. Ideally, we would like this to be based on calculation of current size + 90Mb (Warning), current size + 95Mb (Prohibit Send) and current size + 100Mb (Prohibit Send/Receive) - If we can’t calculate this on the fly, then can these settings be read in and applied from a CSV file. I’m not looking for a completed script (although this would be great, as I’m new to PS), but some guidance as to if this can be done via Powershell for a Ex2003 environment. We are working via a remote admin machine, which has Powershell and the QA cmdlets installed. Any help would be greatly appreciated Cheers D-10
August 2nd, 2010 1:49pm

Hi, have a look into these article for mailbox size report : http://www.outlookexchange.com/articles/glenscales/mreport1.asp http://www.msexchange.org/articles/Scripting-Exchange-VBScript-ADSI-Part3.html http://deludi.nl/blog/vbscript/active-directory/exchange-active-directory-vbscript/active-directory-and-wmi-vbscript-to-enumerate-all-mailboxes-and-their-size-of-your-ad-domain/ Have the name for users which are exceeding or those which are not exceeding the size, move those user to an OU, article : http://www.vistax64.com/powershell/267370-import-csv-users-move-those-users-new-ou.html The you can user ADModify to apply limit to bulk of users. link ADModify: http://admodify.codeplex.com/Ripu Daman Mina | MCSE 2003 & MCSA Messaging
Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2010 2:25pm

Hello, The best way i can suggest is to take the export list of mailboxes using ESM and open that .csv file in Excel. Filter out the mailboxes based on ASC and DESC and then decide the Mailbox Management Policy How to use recipient policies to control mailboxes in Exchange 2000 and Exchange 2003 http://support.microsoft.com/kb/319188 Message age limit properties that are used by Mailbox Manager in Exchange Server 2003 and in Exchange 2000 Server http://support.microsoft.com/kb/302804 Arun Kumar | MCSE:W2K3 + Messaging | MCTS:Exchange 2007 | MCTS:OCS 2007 R2 | ITIL-F V3
August 3rd, 2010 2:09am

Hi Arun / Ripu Firstly, thank you both for your reply - these are areas that we have already looked at, however for various reasons these routes are not really that suitable for our environment. Arun, with regards to the mailbox management response, our management team want to restrict the user by mailbox size - and not by content etc. Ripu, unfortunately the OU route won't work for us either - but that's another story for another forum thread. We have also thought about moving users to different stores, based on their mailbox size - but we don't have the required temporary disk space available to complete the process. We still believe that PowerShell can give us what we need, and had these servers been running Ex2007 we may have been closer to a result, however we are struggling getting the syntax for the Get-WMIObject cmdlet to read the Exchange 2003 servers. Having seen PS also make calculations on the fly, I'm hopeful that we can read in the current size, make the calculation and then write the results as the limits we require. As I say, any help would be great appreciated Thanks D-10
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2010 10:45am

I don't think that using powershell you will be able to query legacy mailboxes. Please let us know, how you have been trying and where exactly you are stuck while working with the Get-WMIObject cmdlet.
August 3rd, 2010 11:30am

Hi MukeshCS I’ve managed to get a little further with the Get-WMIObject cmdlet, and managed to read the mailbox size now. My earlier attempt(s) had a typo in the "Class". This is the command/syntax that I used: Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox |select-object MailboxDisplayName,Size As the syntax suggests, this gets me the mailbox displayname and the size I guess this is where the clever/creative/technical part comes and where I need the most help. Now I have read in the size, I need to make the calculations and apply the settings that I need.
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2010 1:16pm

Hi, You can write a powershell function or a script: These are the 4 attribtues which you need to change, if i were you i would follow these steps: 1. Query using WMI on eXchange for the users's mailbox size ( you already did that) 2. Pass this info to a function which will take this number: for exmaple lets say 50, you can set the warning limit like 10% based on this and and send limit to 40% and send/recieve limit to 80%, you decide those factors. once you calculate these 3 values, then you have set these attributes. mDBUseDefaults = False (Un check the option to use store defaults) mDBStorageQuota = Warning limit mDBOverquotaLimit = Send Limit mDBOverHardQuotaLimit = Send/Recieve Limit. 3. You are done. IF you google enought it is easy to set ad attributes using powershell, so i dont think that it will be difficult. Let me know if this helps, or if you still have questions. thanks ThiyaguThiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
August 3rd, 2010 3:07pm

Hi Thiyagu Thanks for this, it’s very helpful. I have already identified the values that I need to update, and I have been able to write to them with a basic command. Not being any sortof expert on Power shell, I’m struggling on how to make the calculation and pass over the values. :-(
Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2010 3:26pm

With the help of ScriptFanatic, I have more or less what I need. Shay has done all of the clever stuff for me, with this code: $MailboxDisplayName = 'John Doe' # get the mailbox $mbx = Get-Wmiobject Exchange_Mailbox -namespace root\MicrosoftExchangeV2 -Computer ServerName -filter "MailboxDisplayName='$MailboxDisplayName'" # get the user object from AD $user = Get-QADUser $mbx.LegacyDN # get the mailbox size in bytes $mbxByteSize = $mbx.size*1kb # calculate limits [int]$mDBStorageQuota = ($mbxByteSize + 90mb)/1kb # Issue warning at (KB) [int]$mDBOverQuotaLimit = ($mbxByteSize + 95mb)/1kb # Prohibit send at (KB) [int]$mDBOverHardQuotaLimit = ($mbxByteSize + 100mb)/1kb # Prohibit send and receive at (KB) $mDBUseDefaults = $false # apply settings $user | Set-QADUser -ObjectAttributes @{mDBStorageQuota=$mDBStorageQuota;mDBOverQuotaLimit=$mDBOverQuotaLimit;mDBOverHardQuotaLimit=$mDBOverHardQuotaLimit;mDBUseDefaults=$mDBUseDefaults} I'm working feeding this with a list of mailbox acocunts now, but I think i am more or less that. Thanks for all that submitted thier hint/tips
August 4th, 2010 12:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics