Script to create a NLB-cluster for Exchange Server 2010

When documenting installations I perform I prefer to refer to scripts whenever possible, since this means less screenshots and a more concise reference.
When deploying Exchange Server 2010 on Windows Server 2008 R2, we have access to the new PowerShell-module for administering NLB. With this in mind Ive created a script to set up a NLB-cluster for Exchange Server 2010 CAS/Hub-roles in Windows Server 2008 R2.

The script are interactive and will perform the following:

  • Ask for input for variables (cluster FQDN, operation mode, etc.)
  • Create the new cluster based on the variables provided by the user
  • Remove the default port rule
  • Add port rules for http, https, POP3, RPC, IMAP4, SMTP, MSExchange RPC and MSExchange Address Book Service
  • Ask for the addition of additional nodes. Loops through this procedure until the user answers no

Prerequisites:

  • Install the NLB-feature (may be accomplished from the ServerManager module in PowerShell by executing Add-WindowsFeature NLB)
  • Configure the NLB NICs with the approriate name, IP-address and subnetmask (and disable “Register this connections addresses in DNS”)
  • Manually add the cluster FQDN to DNS
  • Configure static ports for the MS Exchange RPC and MS Exchange Address Book Service (see links in the resource section below)
  • Eventually, configure your network switches/routers based on the cluster operation mode you choose

Screenshot:

 image

The script are available from here. In a later revision Im considering adding support for installing the NLB-feature (I dropped it for now since it could only be offered on the server running the script from, not the additional nodes. This can however be accomplished using PowerShell Remoting), setting the dedicated IP-addresses for the NLB NICs and turn off “Register this connections addresses in DNS”.

If you dont want the interactive experience, replace the “Read-Host” sections with the actual variable values.

Please let me know in the comments below if you have any suggestions for improvements.

Related resources

Exchange Server TechCenter: Understanding Load Balancing in Exchange 2010
Exchange Server TechCenter: Load Balancing Requirements of Exchange Protocols
Microsoft TechNet Wiki: Configuring Static RPC Ports on an Exchange 2010 Client Access Server
Bhargav Shukla (MSFT): Script to configure static ports on Exchange Server 2010
Windows Server TechCenter: Network Load Balancing
Microsoft’s Failover and Network Load Balancing Clustering Team Blog: PowerShell for NLB
Kraft Kennedy: Configuring NLB for Exchange 2010 CAS Load Balancing

Script to spread Exchange mailboxes alphabetically across databases

I recently needed to write a script to spread mailboxes in Exchange Server 2010 alphabetically across databases. In my scenario there were 5 databases, and I used a regex switch in PowerShell to assign each mailbox to the correct database based on the first character in the users displayname:

switch -regex ($displayname.substring(0,1))
    {
       "[A-F]" {$mailboxdatabase = "MDB A-F"}
       "[G-L]" {$mailboxdatabase = "MDB G-L"}
       "[M-R]" {$mailboxdatabase = "MDB M-R"}
       "[S-X]" {$mailboxdatabase = "MDB S-X" }
       "[Y-Z]" {$mailboxdatabase = "MDB Y-Z" }
        default {$mailboxdatabase = "MDB Y-Z" }
    }

The reason for the un-even spreading of letters are that the Norwegian language contains 3 extra letters, and I just assign those as well as other non-letter characters to the last database.

The script are available from here. You may of course adjust the number of databases, the ranges of letters to use, which user attribute to sort against (e.g. lastname) and so on to fit your needs.

Although there are several common approaches to provisioning mailboxes across databases, be aware of the new mailbox provisioning load balancer in Exchange Server 2010. If you dont specify a database when creating or moving a mailbox, the load balancer will automatically select the database with the least number of mailboxes. Check out this post by Mike Pfeiffer to see this feature in action.