4

I'm unable to run Backup-SqlDatabase due to errors. 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:

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.

1
  • Did you try this in a fresh PoSH session (ie no other modules loaded whether directly nor by some profile)? Which version of the module SqlServer are you loading (check for multiple parallel module versions, and try to import the module by explicitly loading the intended version)? does the error then still occur? Commented Mar 13, 2017 at 6:06

1 Answer 1

5

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. You can find a good explanation at http://www.mikefal.net/2016/07/12/out-with-the-sqlps-in-with-the-sqlserver/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.