如何使用 PowerShell 5.1 安装 AzureRM 和 AZ 模块?

问题描述

我正在尝试通过 PowerShell 在我的 Windows Server 2016 上安装 Az 模块,但它给了我下面屏幕截图中显示错误

在 Windows 10 服务器上尝试时也会出现相同的错误

如果我尝试安装 Azure RM 命令仍然是同样的错误

我在 Windows 2016 服务器上安装了 .Net Framework 4.8,在 Windows 10 服务器上安装了 .Net 4.7。 两台服务器的PS版本都是5.1。

我尝试参考多个网站上提到的几个解决方案,但似乎没有一个可行。

谁能告诉我我遗漏了什么或者我该如何解决这个错误

enter image description here

解决方法

我过去常常遇到这些错误。

尝试运行:

Find-Module PowerShellGet  | Install-module

如果不是这样应该可以:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

然后你应该可以安装模块了。

参考:https://techcommunity.microsoft.com/t5/windows-powershell/trying-to-install-module-azuread-but-get-psrepository-quot/m-p/202819

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...