我是 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/