![](/img/trans.png)
[英]PowerShell 4 - Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory
[英]Powershell Import-Module SqlServer and SQLPS dont get along
在当前的 Powershell 会话中,我正在运行以下命令
Import-Module SqlServer
Import-Module SQLPS
SqlServer 的导入模块命令工作正常,但 SQLPS 的导入模块命令失败
PS C:\windows\system32> Import-Module SqlServer
PS C:\windows\system32> Import-Module SQLPS
Import-Module : The following error occurred while loading the extended type data file: Error in TypeData
"Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultKeyPropertySet is already present.
Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayPropertySet is already
present.
Error in TypeData "Microsoft.SqlServer.Management.Smo.NamedSmoObject": The member DefaultDisplayProperty is already
present.
At line:1 char:1
+ Import-Module SQLPS
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
我曾尝试使用 Remove-Module 命令删除 SqlServer 模块,但没有成功。 我有一个脚本,它在开始时导入 SqlServer 模块,然后脚本中有某些任务正在使用 SQLPS 模块(并且它因上述错误而失败)。 我猜这两个模块不能在同一个 powershell 会话中加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.