3

In a current Powershell session i am running the following commands

Import-Module SqlServer
Import-Module SQLPS

The Import-Module Command for SqlServer works fine, but Import-Module command for SQLPS fails

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

I have tried removing the SqlServer module using Remove-Module command but no luck. I have a script which is Importing the SqlServer module at the start and then there are certain tasks in the script for which the SQLPS module is being used (and it fails with the above error). I am guessing that these 2 modules cannot be loaded in the same powershell session.

2
  • Have you tried using the -Force switch on the second Import-Module? Or maybe the -NoClobber switch if that one doesn't work? Commented Sep 28, 2020 at 18:38
  • Yes I added the -Force switch and the -NoClobber switches, it does not work Commented Sep 28, 2020 at 18:47

1 Answer 1

1

SQLPS is the older version of the SQLServer module and you are correct; the two are incompatible. The SQLServer module is intended to replicate all functionality from the older version, however.

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.