PowerShell Invoke-WebRequest 获得 403 Forbidden,但随后可以正常工作一段时间

PowerShell Invoke-WebRequest gets 403 Forbidden, but then works ok, for awhile

Win10 Pro 上的 PowerShell 5.1,在家中,在 Comcast 上。
我想获取我的外部 IP。
我的第一个请求得到 403 Forbidden。
但后来我只是重复请求(使用键盘向上箭头),它起作用了——我按预期获得了我的 IP。 但是如果我暂停一会儿(几分钟),我会再次收到 403,然后它就可以工作了

PS>  (Invoke-WebRequest -uri "icanhazip.com").Content

Invoke-WebRequest : The remote server returned an error: (403) Forbidden.
At line:1 char:2
+ (Invoke-WebRequest -uri "icanhazip.com").Content
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

PS>  (Invoke-WebRequest -uri "icanhazip.com").Content
xx.xx.xx.xx  (obscured, but IP as expected)

我可以将 WebRequest 行放入文件并调用它,第一次失败,第二次成功。

我可以将 WebRequest 行两次放入一个文件中,然后调用它 - 它失败一次然后就可以运行,就像在命令行中一样。 我在 PS 7 上没有遇到过这个问题,这使它看起来像是一个 PS5 问题。但是当我使用“https://wtfismyip.com/text”时我也没有得到这个问题,这让它看起来像是一个 icanhazip.com 问题。

Invoke-WebRequest 的默认方法是'Get'。指定方法为'Post',不返回错误。

$response = (Invoke-WebRequest -uri "icanhazip.com" -method Post).Content