簡體   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