繁体   English   中英

Powershell 导入模块 SqlServer 和 SQLPS 不相处

[英]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 会话中加载。

SQLPS 是 SQLServer 模块的旧版本,您是对的; 两者不相容 然而,SQLServer 模块旨在复制旧版本的所有功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM