Configuring Exchange 2013 with Powershell- Part 4: Kemp Load Balancer
Tuesday, April 2, 2013 at 6:42PM
Patch Charron in Exchange 2013, Exchange 2013, Kemp, powershell

I have been a little delayed in posting lately, I am hoping to finish all of the posts for Exchange 2013 now that CU 1 has been released and we can now actually deploy it.

I won't spend too much time talking about the load balancer themselves, but they are highly recomended by me, they are a small company and are quckly becoming the standard for Lync and Exchange.

To do the setup its really easy. Lets first setup our arrays

$kempurl = ""
[array]$kempVSIP = "", "", ""
[array]$kempVSPort = "443", "443", "25"
[array]$kempVSProt = "tcp", "tcp","tcp"
[array]$kempCheckPort = "https", "https", "smtp"
[array]$kempServiceType = "http", "http","gen"
[array]$kempVsDefaultGateway = "", ""
[array]$kempRealServerPort = "443", "443", "25"
[array]$kempcheckURL ="","","" #Make sure this has the same number of URLs as services being created, for SMTP leave null

and then another array of the IPs of our CAS

[array]$kempRealServers = "", ""

For this example I am just creating 3 virtual services, 1 for OWA, EAC, EWS, AS; 1 for Outlook Anywhere; and finally 1 for SMTP. Note that this is an example, There are definaly reasons to create seperate services for each directory. If you want to learn more I highly recommend listening to this epsoide of the UC Architects podcast with Greg Taylor.

Now lets get back to configuring, Before we continue, make sure you have already configured your load balancer and can get a simple connection first, look at this post for help connecting. Now lets add our new virtual services.

        $c = Get-Credential
        for($i = 0; $i -lt $kempVsIP.Length; $i ++) {

        $vs = $kempVsIP[$i]
        $port = $kempVsPort[$i]
        $name = $kempVsName[$i]
        $checkType = $kempCheckPort[$i]
        $defaultGateway = $kempVsDefaultGateway[$i]
        $servicetype = $kempServiceType[$i]
        $realserverport = $kempRealServerPort[$i]
        $checkurl = $kempcheckURL[$i]

            $uri = $kempurl+"/access/addvs?vs=$vs&port=$port&prot=$prot&NickName=""$name""&checktype=$checktype&checkport=$port&DefaultGW=$defaultgateway&VStype=$servicetype&ForceL7=yes&transparent=no"

            if($checkurl -ne ""){
                $uri += "&checkURL=$checkurl"

            $returnXML = Invoke-RestMethod -Uri $uri -Credential $c

            foreach($r in $kempRealServers){
                $uri = $kempurl+"/access/addrs?vs=$vs&port=$port&prot=$prot&rs=$r&rsport=$realserverport"

                Invoke-RestMethod -Uri $uri -Credential $c
            $uri = $kempurl+"/access/showvs?vs=$vs&port=$port&prot=$prot"
            $returnXML = Invoke-RestMethod $uri -Credential $c
            $status = $ReturnXML.Response| Select -ExpandProperty code
            if($status -eq "ok"){

So lets talk through this FOR loop, First, I found that trying to build the long string using the indexes of the arrays to cause inconsistant results, so I just set them to local variables then build the string. Next we just build the string and create the VS, add the check URL and the servers and thats it. Note that in this example we set Layer 7 transparency to off, there are many times where using L7 transparency will benifit your organization.

Thats it, the Kemp Technologies solution is pretty awesome and decently priced. If you haven't checked it out go download the demo here. Up next we will install Exchange 2013!

Article originally appeared on Patch Charron (
See website for complete article licensing information.