Powershell Needful Things put that in your pipeline

28Jan/116

Automatic Custom Mailbox Limits

This little script runs through the Exchange mailboxes and reads the current mailbox size, and sets a new warning limit and send limit for each mailbox, based on the current size.

So basically it looks at the current size of the mailbox, and sets a warning, at current size + 250MB and a send limit, at current size + 350MB. This was a quick workaround for us in an unmanaged environment to quickly establish some method of control without granting over sized limits, in order to accommodate large mailboxes.

This scripts should be run from the Exchange Management Shell.

The code can be copied from here:

$boxes = get-mailbox -resultsize unlimited | Get-MailboxStatistics

Foreach ($box in $boxes)
    {
        $name = $box.DisplayName
        $currentSize = $box.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",", "")
        $WarningQuota = ([int]$currentSize + 262144000)
        $SendQuota = ([int]$currentSize + 367001600)

        Set-Mailbox -Identity $name -IssueWarningQuota $WarningQuota -ProhibitSendQuota $SendQuota
    }
Comments (6) Trackbacks (1)
  1. Jean,

    I appreciate your work and help! This gives me an idea for similar script. A script that a Service Desk could run to up a user’s limit by 250mb or even a 1gb. In our case it is a practice for service desk to give unlimited mailbox – temporarily – to allow users time to get it under control. It would be a nice tool to give the service desk so they could quickly help a user out without risking the environment.

    As I am still learning scripting, powershell, it would help to see the script you have here and the one I have envisioned.

    • Hi Kirk,

      Thanks for your kind comments. And thanks for using the script. If you want, you can use the script that you want to write as a case to start learning PowerShell, and I can guide you along the way?

      Jean

  2. I would need to change the first 2 lines so that the script will promot for a mailbox name – right?

    $boxes = get-mailbox -resultsize unlimited | Get-MailboxStatistics

    Foreach ($box in $boxes)

    • Or we could add the mailbox as a parameter?

      param($alias)
      $mbx = get-mailbox $alias
      write-host “the selected mailbox is” $mbx.name

      to run the script, save as .ps1 and run it with the -alias parameter.

  3. Hi

    I was trying to download the script but it does not work, could you please check if there is any issue or provide any other link to download the scripts.

    • Hi There,

      Thanks for commenting. I am fairly certain that the script works, as I have used it in production. Could you please tell me exactly what error message you get when you run the script?

      You can copy and paste the code from the code block.

      Jean


Leave a comment