Script Center > Repository >
Exchange > Return the Smallest Mailbox Database

Return the Smallest Mailbox Database

Locates the smallest mailbox database (in terms of size) for automatic provisioning process. The script retrieves a collection of mailbox databases, finds the size of each databas

 
 
 
 
 
(2)
Exchange
8/10/2009
E-mail Twitter del.icio.us Digg Facebook
Add To Favorites
Description
Q and A (1)
Online Peer Support For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Sign in to Ask a Question


  • Works fine on the local server.
    2 Posts | Last Post December 11, 2009
    • Works fine when run locally.  I'm working on somethign that might allow this to be useful in an enterprise.  Currently you'd have to log on to each of your servers locally to have this script be valid.  Fine for a single server environment where admin is done on the server.  And useful as a means for determining smallest db size per server.  I took out the sort -property lenght ) [0] to make it return all of my db sizes per server. 
    • would I be able to use this as a variable, like $a? and then call it from within my script so the mailboxes are moved to the smallest DB? and then how can I have another var. that excludes a DB based on size?
      
      # ==============================================================================================
      #
      # NAME: SprayMoves.ps1
      #
      # DESCRIPTION:
      #   Given an input file with a list of SMTP addresses this script will
      #   move those mailboxes to a specified server across all (or part)
      #   of the databases on the server.
      #
      # EXAMPLES:
      #
      #   > .\SprayMoves mblist.txt
      #
      # VERSION: 1.0
      #
      # VERSION HISTORY:
      #   1.0: Phil Braniff - Modification to Inital script provided from Doug Lawty(msft).
      #
      
      param(
        [string] $inputFile = (Read-Host -Prompt "Input file" )
      )
      $AdminSessionADSettings.ViewEntireForest = $true;
      # Check to see if the provided file name exists.
      if ( Test-Path $inputFile ) {
        $addressList = Get-Content $inputFile;
        # The file can either have a header row or not. If it does, remove it.
        if ( ! ($addressList[0].Contains("@")) ) { $addressList = $addressList[1..($addressList.Length - 1)]; }
      } else {
        Write-Host "Specified address list does not exist!" -ForegroundColor Red
        exit;
      }
      $serverName = (Read-Host -Prompt "Supply the destination Server name for these moves:" )
      $database = "\SG1\1MBX1","\SG2\2MBX1","\SG3\3MBX1","\SG4\4MBX1","\SG5\5MBX1","\SG6\6MBX1","\SG7\7MBX1"
      $i = 0
      foreach ( $address in $addressList ) {
        $db = $($serverName) ($database[$i])
        Move-Mailbox -id $address.trim() -targetdatabase $db -BadItemLimit 50 -PreserveMailboxSizeLimit:$true -Confirm:$False -whatif;
        $i = $i 1
        if ($i -eq $database.length)
        {
           $i = 0
        }
      }