gpt4 book ai didi

找不到 powershell -Scope 参数

转载 作者:行者123 更新时间:2023-12-04 14:55:51 25 4
gpt4 key购买 nike

很奇怪。我正在尝试升级 oh-my-posh从 v2 到 v3,方法被记录 here .但是,当我运行命令时

Update-Module -Name oh-my-posh -Scope CurrentUser
Powershell 显示
Update-Module : A parameter cannot be found that matches parameter name 'Scope'.
At line:1 char:32
+ Update-Module -Name oh-my-posh -Scope CurrentUser
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Update-Module], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Update-Module
我见过很多人用这个 -Scope参数非常频繁。我不明白为什么我的 powershell 找不到这个参数。
使用 Windows(集成)Powershell,$PSVersionTable:
PSVersion                      5.1.19041.1023
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1023
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

最佳答案

Update-Module 的版本Windows PowerShell 版本最高 v5[1] 显然没有 -Scope参数 - 请参阅链接的帮助主题。
帮助主题表明,PowerShell session 是否提升(以管理员身份运行)暗示了目标范围,其中 AllUsers范围是否有针对性,在这种情况下 CurrentUser是暗示。
但是,您应该能够更新 PowerShellGet module , 其中 Update-Module cmdlet 是 PowerShell Gallery 的一部分,它应该会给你一个 -Scope之后的参数:

# Run from an ELEVATED session.
# Initial upgrade to the latest version from the PowerShell Gallery.
# Thereafter, use `Update-Module PowerShellGet` to update.
Install-Module -Scope AllUsers PowerShellGet -Force # Add -Verbose for details.

[1] 我看到你的版本是 v5.1 - 而你的 PowerShellGet模块似乎已经过时;可以想象,手动安装的旧版本正在掩盖捆绑的版本。

关于找不到 powershell -Scope 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68034974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com