Share via

Powershell script error:- Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.

Anonymous
2019-03-23T03:21:14+00:00

i Guys,

I am using one script . it was working fine before 6 days but now giving error. I am using the Labtech software to monitor machines. when monito fails then this script runs on machine and send the result to opsGenis email. then ops genie sends the alert on phone via SMS or voice call. 

this is the error when script run on server . FYI, server is exchange server.

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure 

channel.

At C:\Windows\system32\config\systemprofile\AppData\Local\9e1cd5b9f46d4e17b9179

fbe197f1909.ps1:36 char:11

  • $result = Invoke-RestMethod -Method "Post" -Uri $uri -Headers $headers -Body 

$bo ...

  • 
    

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt 

pWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe 

ll.Commands.InvokeRestMethodCommand

This is the script :-

param (

  [string]$eu = "False",

  [string]$apiKey = "apiKey",

  [string]$status = "status",

  [string]$clientname = "client",

  [string]$computername = "computer",

  [string]$locationname = "location",

  [string]$fieldname = "field",

  [string]$result = "result",

  [string]$when = "when",

  [string]$contactName = "contact",

  [string]$monitorName = "monitor"

)

  if($eu -eq "True") {

  $uri = "https://api.eu.opsgenie.com/v1/json/integrations/webhooks/connectwiseautomate?apiKey=" + $apiKey;

}

else {

  $uri = "https://api.opsgenie.com/v1/json/integrations/webhooks/connectwiseautomate?apiKey=" + $apiKey;

}

$body = ConvertTo-Json @{

  status = $status

  clientName = $clientname

  computerName = $computername

  locationName = $locationname

  fieldName = $fieldname

  result = $result

  when = $when

  contactName = $contactName

  monitorName = $monitorName

}

$headers = [Hashtable] @{

    Type = 'application/json'

};

$result = Invoke-RestMethod -Method "Post" -Uri $uri -Headers $headers -Body $body -ContentType 'application/json'

Write-Output $result

Thanks
Windows for home | Other | Install and upgrade

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Sumit D - IA 166.2K Reputation points Independent Advisor
    2019-03-23T03:25:00+00:00

    Hi Barinder,

    As this is a Windows consumer only forum, you can get better help by posting it on Technet Powershell forums:

    Technet forums - Windows PowerShell - Microsoft

    https://social.technet.microsoft.com/Forums/Win...

    0 comments No comments