简体   繁体   English

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

[英]Unable to install Az powershell module with PS7 on windows10

I am administrator on my Windows10, and trying to install Azure PS module as per the documentation in here .我是 Windows10 的管理员,并尝试按照此处的文档安装 Azure PS 模块。

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

However, I get the error message as below.. 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.但是,我收到如下错误消息。 Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711 Line 9711 talledPackages = PackageManagement\Install-Package @PSBoundParameters 需要管理员权限才能安装或更新。 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.使用具有管理员权限的帐户登录计算机,然后重试,或通过在命令中添加“-Scope CurrentUser”来安装。 You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).您也可以尝试以提升的权限运行 Windows PowerShell session(以管理员身份运行)。

It does not make sense why it throws this error even though I am already in admin privilege mode .即使我已经处于管理员特权模式,它为什么会抛出此错误也没有意义 Few other SO answers asked to set to use TLS 1.2, I have done that as well.很少有其他 SO 答案要求设置为使用 TLS 1.2,我也这样做了。 Like so [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 .像这样[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

What else could be the issue?还有什么问题?

Trying to install az module over existing modules will give this error and it appears to be the cause for this issue.尝试在现有模块上安装 az 模块会出现此错误,这似乎是导致此问题的原因。

The way to solve this issue is by deleting already existing not in use previous az modules which you can find in the following path -解决此问题的方法是删除已经存在但未使用的以前的 az 模块,您可以在以下路径中找到这些模块 -

C:\Program Files\WindowsPowerShell\Modules . C:\Program Files\WindowsPowerShell\Modules

Then run the following command -然后运行以下命令 -

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force -AllowClobber

And this will solve your problem.这将解决您的问题。

Also look at az module falsely throws Admin rights required error.还要查看az 模块错误地抛出 Admin rights required 错误。

You can also check this discussion and find the similar answer in this comment.您也可以查看此讨论并在此评论中找到类似的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM