当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 安装模块 MSOnline 失败,无法从 URI 下载

作者:精品下载站 日期:2024-12-14 07:06:11 浏览:14 分类:玩电脑

安装模块 MSOnline 失败,无法从 URI 下载


在 PowerShell 中使用 Install-Module MSOnline 命令安装 MSOnline 模块时,它会失败并出现如下神秘错误:

警告:无法从 URI“https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409’”下载到”。
警告:无法下载可用提供商的列表。检查您的互联网连接。
PackageManagement\Install-PackageProvider :未找到与提供程序“NuGet”的指定搜索条件匹配的内容。包提供程序需要“PackageManagement”和“Provider”标签。请检查指定的包是否有标签。

警告:无法从 URI“https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409’”下载到”。
警告:无法下载可用提供商的列表。检查您的互联网连接。
PackageManagement\Get-PackageProvider:无法找到包提供程序“NuGet”。可能还没有导入。尝试“Get-PackageProvider -ListAvailable”。
Install-Module :需要 NuGet 提供程序才能与基于 NuGet 的存储库进行交互。请确保安装“2.8.5.201”或更高版本的 NuGet 提供程序。

如下图所示:

[玩转系统] 安装模块 MSOnline 失败,无法从 URI 下载

事实证明,这是一个 TLS 问题,PowerShell 默认情况下不使用 TLS 1.2,而 Microsoft 要求客户端使用 TLS 1.2。要设置 PowerShell 的 TLS 1.2 使用情况,可以使用以下命令:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

现在,如果您再试一次,它将安装 MSOnline 模块:

[玩转系统] 安装模块 MSOnline 失败,无法从 URI 下载

这是每个会话的设置,如果要为所有会话启用它,请将前面的命令添加到 Microsoft.PowerShell_profile.ps1 和 Microsoft.PowerShellISE_profile.ps1 配置文件(为此使用记事本 $Profile)。

更多信息

Azure ActiveDirectory (MSOnline) - https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-msonlinev1?view=azureadps-1.0

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯