简体   繁体   English

在Powershell中使用Backup-SqlDatabase时出现“TypeData错误”错误

[英]“Error in TypeData” errors when using Backup-SqlDatabase in Powershell

I'm unable to run Backup-SqlDatabase due to errors. 由于错误,我无法运行Backup-SqlDatabase。 I get the following: 我得到以下内容:

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

I run Import-Module as suggested and get this: 我按照建议运行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

I recently installed SQL Server 2016 alongside 2012, am not sure if this has contributed to the problem as I had not used any of these Powershell commands prior. 我最近在2012年安装了SQL Server 2016,我不确定这是否导致了这个问题,因为我以前没有使用过任何这些Powershell命令。

Make sure you are not importing SQLPS which is the module installed with SQL Server prior to 2016. SqlServer is the module associated with SQL Server 2016 and can be used for previous SQL versions. 确保您没有导入SQLPS ,它是2016年之前安装SQL Server的模块.SqlServer是与SQL Server 2016关联的模块,可用于以前的SQL版本。 You can find a good explanation at http://www.mikefal.net/2016/07/12/out-with-the-sqlps-in-with-the-sqlserver/ 您可以在http://www.mikefal.net/2016/07/12/out-with-the-sqlps-in-with-the-sqlserver/找到一个很好的解释

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

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