getting “Exception calling ”GetResponse" while getting cache size in kemp using powershell script

I am trying to get cache size from Kemp server using power shell script. Following is thew script I am using to do so. But keep getting "Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: An unexpected error occurred on a send"

$uri = ""

$username = "bal" $password = "XXXXXXX" strong text

$secPw = ConvertTo-SecureString $password -AsPlainText -Force

$Credential = New-Object PSCredential -ArgumentList $username,$secPw

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

please guide what is causing this error. Not good in powershell.

  • What you have submitted does is not really complete enough to see what you are really doing.

    What version of PowerShell are you using?
    Are you using the Kemp PowerShell module?


    Be aware that it has its own impacts.

    Note, that when calling after web information, you'd use either the Invoke-WebRequest and / or Invoke-RestMethod if you are on v3 or higher. If you are below that, then you'd have to leverage the .Net framework directly. Specifically [System.Net.WebRequest] and / or [System.Net.HttpWebRequest]. The Kemp PoSH modules leverage RestApi to do it's work. In according to it's own documentation.
Reply Children