【发布时间】:2019-10-30 01:53:03
【问题描述】:
WPS = Windows PowerShell
PSC = PowerShell 核心
当我开始时,我有三 (3) 个路径作为系统环境变量 PSModulePath 的一部分。
%ProgramFiles%\WindowsPowerShell\Modules
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
我假设 SQL Server 的安装创建了最后一个。但是,我删除了前两个,看看 PowerShell 是否可以找到自己的方式,或者他们是否需要它们?
WPS 5.1 64-bit appears to start ok, but ISE reports an error finding `ISE`.
PSC 6.2 starts ok. There is no ISE.
PSC 7.0 starts ok. There is no ISE.
我不得不将%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules 目录放回系统环境变量PSModulePath。之后,WPS 5.1 和 ISE 正常启动。
WPS 5 在启动之前是否需要PSModulePath 中的 System32 目录?我想删除它。而且,实际上,我想将 SQL Server 目录移动到更合适的位置。有更好的地方吗?我经常从 .bat 文件脚本运行powershell -NoProfile,所以我认为六 (6) 个配置文件脚本(如果添加 32 位,则为 12 个)中的任何一个都不是一个好地方。你有什么建议?
更新
=== 启动 cmd.exe
C:>echo %PSModulePath%
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\;
=== 运行 powershell.exe 5.1.18362.145
C:>$Env:PSModulePath
C:\Users\lit\Documents\WindowsPowerShell\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\;C:\Program Files\WindowsPowerShell\Modules
=== 运行 ise
ipmo : The specified module 'ISE' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ ipmo ISE
+ ~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (ISE:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
【问题讨论】:
-
system32位置包含许多重要模块(包括关键的 PowerShell 模块),PsModulePath是 PowerShell 找到它们的方式。我可以理解 SQL 模块,因为它位于非标准位置,但您为什么要删除其他位置?