AntoineGS / TeamsStatusV2

Monitoring your Microsoft Teams status with PowerShell
MIT License
40 stars 5 forks source link

Could not create SSL/TLS secure channel #25

Closed 1kohm closed 11 months ago

1kohm commented 1 year ago

Hi,

I'm not able to start the Get-TeamsStatus.ps1 script.

I did add TSHATOKEN and TSHAURL as system variable in Windows 10 TSHAURL: https://myha.domain.com TSHATOKEN: eyJhbGc..... (long token) I can access my ma from outside via other API

that's the output of the script:

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At C:\Users\test\source\TeamsStatusV2-main\TSFunctions.ps1:21 char:5
+     Invoke-RestMethod -Uri "$HAUrl/api/states/$entityId" -Method POST ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc 
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At C:\Users\test\source\TeamsStatusV2-main\TSFunctions.ps1:21 char:5
+     Invoke-RestMethod -Uri "$HAUrl/api/states/$entityId" -Method POST ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc 
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

How to resolve that issue?

Thanks

AntoineGS commented 1 year ago

After some googling I found this: link. Can you try editing the TSFunctions.ps1 file and adding: [Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls11, Tls, Ssl3" Before: Invoke-RestMethod -Uri "$HAUrl/api/states/$entityId" -Method POST -Headers $headers -Body ([System.Text.Encoding]::UTF8.GetBytes($params)) -ContentType "application/json"

To see if it fixes it? I do not currently use https on my HA installation.