如何解决Powershell Invoke-RestMethod无法连接到远程服务器
我制作了一个超级简单的powershell脚本,用于在电报中发送消息。在我的计算机上,我具有PowerShell ISE 5.1,在远程计算机上,我也具有相同版本。当我在计算机上运行脚本时,脚本可以正常运行,但是在运行远程计算机时,会发生此错误:
Invoke-RestMethod:无法连接到远程服务器 InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-RestMethod] WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
错误图片:https://i.stack.imgur.com/YfDaA.png
这是我的代码:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Host " ## FINALIZACAO DE MANOBRA ##"
$MyToken = "1221791202:AAExOCCKGou6tHV662HmMOxJyN28If46bqY"
$chatID = "-451595204"
$Message = @("Maneuver performed.")
$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($MyToken)/sendMessage?chat_id=$($chatID)&text=$($Message)"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。