【问题标题】:"Error in TypeData" errors when using Backup-SqlDatabase in Powershell在 Powershell 中使用 Backup-SqlDatabase 时出现“TypeData 错误”错误
【发布时间】:2017-08-03 01:16:36
【问题描述】:

由于错误,我无法运行 Backup-SqlDatabase。我得到以下信息:

PS C:\Users\Mik> Backup-SqlDatabase
Backup-SqlDatabase : The 'Backup-SqlDatabase' command was found in the module 'SqlServer', but the module could not be
loaded. For more information, run 'Import-Module SqlServer'.
At line:1 char:1
+ Backup-SqlDatabase
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Backup-SqlDatabase:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

我按照建议运行 Import-Module 并得到这个:

PS C:\Users\Mik> Import-Module SqlServer
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 SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

我最近在 2012 旁边安装了 SQL Server 2016,我不确定这是否会导致问题,因为我之前没有使用过任何这些 Powershell 命令。

【问题讨论】:

  • 您是否在新的 PoSH 会话中尝试过此操作(即没有其他模块直接加载或通过某些配置文件加载)?您正在加载哪个版本的模块SqlServer(检查多个并行模块版本,并尝试通过显式加载预期版本来导入模块)?那么错误是否仍然发生?

标签: sql-server powershell sqlps


【解决方案1】:

确保您没有导入 SQLPS,这是 2016 年之前随 SQL Server 安装的模块。SqlServer 是与 SQL Server 2016 关联的模块,可用于以前的 SQL 版本。你可以在http://www.mikefal.net/2016/07/12/out-with-the-sqlps-in-with-the-sqlserver/找到一个很好的解释

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-15
    • 2010-10-30
    • 2020-08-14
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多