能给我解释一下吗?
Import-Module PSReadLine -Scope CurrentUser
Import-Module : Cannot validate argument on parameter 'Scope'.
The argument "CurrentUser" does not belong to the set "Local,Global"
specified by the ValidateSet attribute. Supply an argument that is in the
set and then try the command again.
At line:1 char:37
+ Import-Module PSReadLine -Scope CurrentUser
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Import-Module], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportModuleCommand但是这个很好(!)
Install-Module PSScriptAnalyzer -Scope CurrentUser这很好(!)
Import-Module PSReadLine -Scope LocalInstall-Module的帮助文件甚至不承认错误中提到的Local|Global的存在。-Scope <String> Specifies the installation scope of the module. The acceptable values for this parameter are AllUsers and CurrentUser.
发布于 2020-02-16 15:59:39
这些范围大不相同(摘自官方learn.microsoft.com):
指定,此cmdlet将模块导入其中。。 此参数的可接受值为: Global.会话中的所有命令都可用。等效于全局参数。 Local.仅在当前范围内可用。 默认情况下,当从命令提示符、脚本文件或scriptblock调用时,所有命令都导入到全局会话状态。您可以使用带有本地值的-Scope参数将模块内容导入到脚本或scriptblock范围。 从另一个模块调用时,将模块中的命令(包括嵌套模块中的命令)导入到调用方的会话状态中。指定-Scope全局或-Global表示此cmdlet将模块导入全局会话状态,使其可供会话中的所有命令使用。
指定模块的安装范围。这个参数的可接受值是AllUsers和CurrentUser。 AllUsers作用域在计算机的所有用户都可以访问的位置安装模块: $env:ProgramFiles\PowerShell\Modules CurrentUser将模块安装在只有计算机的当前用户才能访问的位置: $home\Documents\PowerShell\Modules 如果未定义范围,则根据PowerShellGet版本设置默认值。
发布于 2020-07-10 13:29:56
对于我和那些面临类似问题的人来说,我不得不在CurrentUser周围加上花括号"{}“。否则什么都没发生。
示例:安装模块-Name SimplySql -Scope {CurrentUser}
https://stackoverflow.com/questions/60249072
复制相似问题