Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PowerShell 4-导入模块:指定的模块';SQLPS';未加载,因为在任何模块目录中找不到有效的模块文件_Powershell_Import Module_Sqlps - Fatal编程技术网

PowerShell 4-导入模块:指定的模块';SQLPS';未加载,因为在任何模块目录中找不到有效的模块文件

PowerShell 4-导入模块:指定的模块';SQLPS';未加载,因为在任何模块目录中找不到有效的模块文件,powershell,import-module,sqlps,Powershell,Import Module,Sqlps,以前使用过PowerShell 3。升级到PowerShell 4并按错误说明将其卸载。 导入模块:未加载指定的模块“SQLPS”,因为在任何模块目录中都找不到有效的模块文件。但是所有与SQL相关的内容都正常工作,没有出现错误。PowerShell控制台中此错误的根本原因是什么?听起来您需要手动更新模块路径 检查计算机上是否存在此目录 C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS [

以前使用过PowerShell 3。升级到PowerShell 4并按错误说明将其卸载。
导入模块:未加载指定的模块“SQLPS”,因为在任何模块目录中都找不到有效的模块文件。
但是所有与SQL相关的内容都正常工作,没有出现错误。PowerShell控制台中此错误的根本原因是什么?

听起来您需要手动更新模块路径

检查计算机上是否存在此目录

C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS
[固定]

如果是这样,它就会运行

$env:PSModulePath = $env:PSModulePath + ";C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules"
然后使用查看SQLPS模块是否在可用模块列表中

get-module -listavailable

这只是正常的错误。

Step: 1 - We have to check the Path[[ C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS]] is available in our machine.

If yes, follow step 2

Step: 2. Just copy the [SQLPS] folder from the above link 

Step: 3. Paste the same in [[C:\Windows\system32\WindowsPowerShell\v1.0\Modules\\\

Step: 4 Its been occur due to unavailability of the SQLPS

当您以交互方式运行该命令时,或者当您让它设置计划任务或其他内容时,是否会发生此错误?您是否尝试运行$env:PSModulePath并检查该模块是否确实仍然存在?在PowerShell 3中,SQLPS模块存在于$env:PSModulePath中。但在安装PowerShell 4之后,它就不存在了;C:\ProgramFiles(x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS“因为目录存在。然后执行get module-listavailable,SQLPS可用,但仍然面临相同的错误。如果重新启动power Shell编辑器,则SQLPS未在get module-listavailable中列出。请在添加psmodulepath路径时尝试删除SQLPS部分。
$env:psmodulepath=$env:psmodulepath+;“C:\Program Files(x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules”
是,这是正常行为。每次打开powershell时,环境变量都将重置。您可以运行“sysdm.cpl”-->Advanced-->环境变量并在其中修改PSModulePath路径,也可以尝试将SQLPS模块复制到power shell模块的系统路径,路径为C:\Windows\system32\WindowsPowerShell\v1.0\modules\Great!!我已在C:\Windows\system32\WindowsPowerShell\v1.0\Modules的power shell模块上复制了SQLPS模块。它工作得很好。.请注意,
SQLPS
模块现在被弃用,取而代之的是
SqlServer
模块,它可以通过
Install module SqlServer
安装。请参阅以供参考。