powershell - Powershell 版本 2 配置系统初始化失败
问题描述
我正在使用 PowerShell 创建一个脚本来向端点发出 http 请求。我知道从 PowerShell 版本 3 开始,我可以使用Invoke-RestMethod
or Invoke-WebRequest
,但脚本需要与 PowerShell 版本 2 兼容。由于我搜索并阅读了许多论坛,最常见的解决方案是使用 .Net 类System.Net.WebRequest
。我正在执行以下几行:
$Uri = "https://url"
$Web = [System.Net.WebRequest]::Create($Uri)
我面临以下错误:
Create : Exception calling "Create" with "1" argument(s): "Configuration system failed to initialize"
At line:1 char:32
+ [System.Net.WebRequest]::Create <<<< ($Uri)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
你能帮忙解决一下可能导致这个问题的原因吗?
解决方案
推荐阅读
- reactjs - React - 如何过滤手风琴标题
- javascript - Uncaught (in promise) TypeError: window.showOpenFilePicker is not a function
- python - 将消息从 RabbitMQ 队列发送到 Websocket 连接,反之亦然
- node.js - 从自定义 lambda 自定义中间件返回错误
- themes - CKeditor 5 背景颜色变化
- reactjs - React Native Web/Expo:如何在 Pressable 上模拟焦点可见?
- php - Laravel/codeception 测试:如何存根 time()
- aws-lambda - 将 dynamodb 流事件源触发器配置为具有可配置的重试延迟
- spring-boot - Spring JPA 存储库方法来获取排序的不同和非空值
- r - 从不等向量长度的列表中创建 data.table