问题描述
我制作了一个超级简单的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 (将#修改为@)