Managing Kemp LoadMaster using REST API and PowerShell

If you are an application or a network administrator, you would have certainly heard about or even used load balancers. Load balancers are shipped either as hardware or virtual appliances based on the size of the deployment behind them. Today, almost every load balancer vendor offers both varieties. Kemp Technologies, our technology partner and a new entrant in Gartner magic quadrant for Application Delivery Controllers (ADC) offers both hardware and virtual appliances.

While Kemp load balancers have a very intuitive and easy to use web-based user interface for managing load balancing configuration, Kemp also offers a RESTFul API to script the Kemp load balancer management – whether it is a hardware or a virtual appliance. One thing to remember is that the REST API interfaces need to be enabled in Kemp Web User Interface (WUI). By default, they are disabled.

Now, with PowerShell, it is very easy to work with REST API. Kemp structured its API in a very easy way. The general syntax for any REST API method in KEMP REST interfaces is something like this:


Note that the Invoke-RestMethod and the Invoke-WebRequest have issues with accessing REST API over HTTPS and basic authorization. You will find, over many forums, that there are workarounds. For the purpose of this post, I will use a simple .NET HttpWebRequest.

So, for getting the maximum cache size setting on the KEMP LoadMaster, we can simply call https://<LoadMaster IPAddress>/access/get?param=cachesize

This API returns XML output which can be easily parsed using PowerShell.

Now, let us look at some PowerShell code that can be used to access the cache size setting on the LoadMaster appliance.

$uri = ""
$credential = Get-Credential -UserName bal

[System.Net.ServicePointManager]::Expect100Continue = $true
[System.Net.ServicePointManager]::MaxServicePointIdleTime = 10000
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$request = [System.Net.HttpWebRequest]::Create($uri)
$request.Credentials = $Credential

$response = $request.GetResponse()

$stream = $response.GetResponseStream()
if($response.contenttype -eq "text/xml") {
    $Encoding = [System.Text.Encoding]::GetEncoding("utf-8")
    $reader = New-Object$stream, $Encoding)
    $result = $reader.ReadToEnd()
    if ($result.response.success) {
        if ([string]::IsNullOrEmpty($ {
             Write-Output $result.response.code
        } else {
             Write-output $
    else {
         Write-Output $result.response

As you see, we see the cache size setting on my LoadMaster VM. Now, the above code can be put into a simple and re-usable function to access different methods provided in the Kemp REST API.

If you want to explore more on how to use Kemp REST API and what you can do with it, Kemp provides a trial license of LoadMaster as a VM. This is available for various hypervisors and VMware Workstation too. Go ahead and give it a try.

Here is a teaser: In our upcoming posts, we will show you how easy it is to manage a Kemp LoadMaster using better ways than writing the functions and dealing with the REST API youself. Stay tuned.

Share on: