PoshCode Logo PowerShell Code Repository

New-Exch2010NlbCluster by Jan Egil Ring 6 years ago
View followups from Ranjith | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1868"></script>download | new post

Script to create a NLB-cluster for the CAS/HUB-roles in Exchange Server 2010.
For more details, see the following blog-post: http://blog.powershell.no/2010/05/21/script-to-create-a-nlb-cluster-for-the-cas-role-in-exchange-server-2010

  1. ###########################################################################
  2. #
  3. # NAME: New-Exch2010NlbCluster.ps1
  4. #
  5. # AUTHOR: Jan Egil Ring
  6. # EMAIL: jer@powershell.no
  7. #
  8. # COMMENT: Script to create a NLB-cluster for the CAS/HUB-roles in Exchange Server 2010.
  9. #          For more details, see the following blog-post: http://blog.powershell.no/2010/05/21/script-to-create-a-nlb-cluster-for-the-cas-role-in-exchange-server-2010
  10. #
  11. # You have a royalty-free right to use, modify, reproduce, and
  12. # distribute this script file in any way you find useful, provided that
  13. # you agree that the creator, owner above has no warranty, obligations,
  14. # or liability for such use.
  15. #
  16. # VERSION HISTORY:
  17. # 1.0 20.05.2010 - Initial release
  18. #
  19. ###########################################################################
  20.  
  21. #Importing Microsoft`s PowerShell-module for administering NLB Clusters
  22. Import-Module NetworkLoadBalancingClusters
  23.  
  24. #Variables for creating the new cluster
  25. $ClusterFqdn = Read-Host "Enter FQDN for the new cluster"
  26. $InterfaceName = Read-Host "Enter interface name for NLB-adapter"
  27. $ClusterPrimaryIP = Read-Host "Enter cluster primary IP"
  28. $ClusterPrimaryIPSubnetMask = Read-Host "Enter subnetmask for cluster primary IP"
  29.  
  30. Write-Host "Choose cluster operation mode"
  31. Write-Host "1 - Unicast"
  32. Write-Host "2 - Multicast"
  33. Write-Host "3 - IGMP Multicast"
  34. switch (Read-Host "Enter the number for your chosen operation mode")
  35. {
  36. 1 {$OperationMode = "unicast"}
  37. 2 {$OperationMode = "multicastcast"}
  38. 3 {$OperationMode = "igmpmulticast"}
  39. default {Write-Warning "Invalid option, choose '1', '2' or '3'";return}
  40. }
  41.  
  42. $MSExchangeRPCPort = Read-Host "Enter static port configured for Microsoft Exchange RPC (MAPI)"
  43. $MSExchangeABPort = Read-Host "Enter static port configured for Microsoft Exchange Address book service"
  44.  
  45. #Creating new cluster
  46. Write-Host "Creating NLB Cluster..." -ForegroundColor yellow
  47. New-NlbCluster -ClusterName $ClusterFqdn -InterfaceName $InterfaceName -ClusterPrimaryIP $ClusterPrimaryIP -SubnetMask $ClusterPrimaryIPSubnetMask -OperationMode $OperationMode
  48.  
  49. #Removing default port rule for the new cluster
  50. Write-Host "Removing default port rule..." -ForegroundColor yellow
  51. Get-NlbClusterPortRule -HostName . | Remove-NlbClusterPortRule -Force
  52.  
  53. #Adding port rules for Exchange Server 2010 CAS (SMTP, http, POP3, RPC, IMAP4, https, static port for MSExchangeRPC and MSExchangeAB)
  54. Write-Host "Adding port rules for Exchange Server 2010 CAS" -ForegroundColor yellow
  55. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 25 -EndPort 25 -InterfaceName $InterfaceName | Out-Null
  56. Write-Host "Added port rule for SMTP (tcp 25)" -ForegroundColor yellow
  57. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 80 -EndPort 80 -InterfaceName $InterfaceName | Out-Null
  58. Write-Host "Added port rule for http (tcp 80)" -ForegroundColor yellow
  59. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 110 -EndPort 110 -InterfaceName $InterfaceName | Out-Null
  60. Write-Host "Added port rule for POP3 (tcp 110)" -ForegroundColor yellow
  61. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 135 -EndPort 135 -InterfaceName $InterfaceName | Out-Null
  62. Write-Host "Added port rule for RPC (tcp 135)" -ForegroundColor yellow
  63. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 143 -EndPort 143 -InterfaceName $InterfaceName | Out-Null
  64. Write-Host "Added port rule for IMAP4 (tcp 143)" -ForegroundColor yellow
  65. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 443 -EndPort 443 -InterfaceName $InterfaceName | Out-Null
  66. Write-Host "Added port rule for https (tcp 443)" -ForegroundColor yellow
  67. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort $MSExchangeRPCPort -EndPort $MSExchangeRPCPort -InterfaceName $InterfaceName | Out-Null
  68. Write-Host "Added port rule for MSExchange RPC (tcp $MSExchangeRPCPort)" -ForegroundColor yellow
  69. Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort $MSExchangeABPort -EndPort $MSExchangeABPort -InterfaceName $InterfaceName | Out-Null
  70. Write-Host "Added port rule for MSExchange Address Book service (tcp $MSExchangeABPort)" -ForegroundColor yellow
  71.  
  72. #Adding additional cluster nodes based on user input
  73. Write-Warning "Before adding additional nodes, make sure that NLB are installed and the NLB-adapter are configured with a static IP-address on the remote node"
  74. $additionalnodes = Read-Host "Add additional nodes to the cluster? Y/N"
  75. if ($additionalnodes -like "y"){
  76. do {
  77. $NodeFqdn = Read-Host "Enter FQDN for the additional node"
  78. $NewNodeInterface = Read-Host "Enter interface name for NLB-adapter on the additional node"
  79. Write-Host "Adding cluster node $NodeFqdn" -ForegroundColor yellow
  80. Get-NlbCluster -HostName . | Add-NlbClusterNode -NewNodeName $NodeFqdn -NewNodeInterface $NewNodeInterface
  81. $additionalnodes = Read-Host "Add additional nodes to the cluster? Y/N"
  82. } until ($additionalnodes -like "n")
  83. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me