Reputation: 89
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.
Upvotes: 2
Views: 5479
Reputation: 411
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.
Upvotes: 1