azure - 无法在 windows10 上使用 PS7 安装 Az powershell 模块

标签 azure powershell azure-powershell

我是 Windows10 的管理员,并尝试按照 here 中的文档安装 Azure PS 模块.

PS C:\Program Files\PowerShell\7> Install-Module -Name Az -Scope CurrentUser -Force -Allowclobber

但是,我收到如下错误消息..

Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711
Line 9711 talledPackages = PackageManagement\Install-Package @PSBoundParameters

Administrator rights are required to install or update. Log on to the computer with an account that has Administrator rights, and then try again, or install by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

即使我已经处于管理员权限模式,它为什么会抛出此错误也是没有意义的。很少有其他答案要求设置使用 TLS 1.2,我也这样做了。 就像这样:

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

还有什么问题可能吗?

最佳答案

尝试在现有模块上安装 az 模块会出现此错误,这似乎是导致此问题的原因。

解决此问题的方法是删除已存在的未使用的先前 az 模块,您可以在以下路径中找到这些模块 -

C:\Program Files\WindowsPowerShell\Modules

然后运行以下命令 -

安装模块-Name Az -Scope CurrentUser -Repository PSGallery -Force -AllowClobber

这将解决您的问题。

另请参阅az module falsely throws Admin rights所需的错误。

您还可以查看此 discussion并在this comment.中找到类似的答案

关于azure - 无法在 windows10 上使用 PS7 安装 Az powershell 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69206978/

相关文章:

azure - 如何关闭动态架构支持?

powershell - 如何从Powershell向手机发送短信

powershell - 新-AzureRmVM : Parameter set cannot be resolved using the specified named parameters

powershell - Add-AzureAccount : Index was out of range. 必须是非负数且小于集合的大小

azure - 持久存储 Azure 容器

Azure B2C Graph API - 强制用户在下次登录时更改密码

azure - Blob 属性被忽略

powershell - Powershell计算的列中断表

regex - 仅过滤文件中的大写单词

azure - 通过 Azure powershell 仅获取企业应用程序