SqlServer PS module and SQLPS Clarification

Copper Contributor

I've already started a thread last week about this on the SQL MSDN forums and have not gotten anywhere. So I'm hoping that since this might be more of PS thing, maybe you fine folks could shed some light.


I understand that SqlServer has replaced SQLPS. I experienced this with SQL 2017. I'm now putting together a SQL 2019 with Server 2019 and I see that SQLPS is still part of the install.


PS C:\Windows\system32> get-module sqlps -ListAvailable

Directory: C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules

ModuleType Version Name ExportedCommands

---------- ------- ---- ----------------

Manifest 15.0 SQLPS {Backup-SqlDatabase, Save-SqlMigrationReport, Invoke-Polic...


Before I do an install of SqlServer module, is it advised to uninstall SQLPS first? I did try to install SqlServer without trying to remove SQLPS and I'm then presented with all sorts of red text


PackageManagement\Install-Package : The following commands are already available on this system:'Add-SqlAvailabilityDatabase,Add-SqlAvailabilityGroupListenerStaticIp,Add-SqlFirewallRule,Backup-SqlDatabase,blah blah blah....'. This module 'SqlServer' may override the existing commands. If you still want to install this module 'SqlServer', use -AllowClobber parameter.


Should one just -AllowClobber? When I do that, both SQLPS and SqlServer appear to be installed.


Someone from that SQL forum did suggest to uninstall SQLPS. However, that brings up more issues.


I attempted to Uninstall-Module and Remove-Module with no luck.


PS C:\Windows\system32> Uninstall-Module -Name sqlpsPackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'sqlps'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2194 char:21
+ ... $null = PackageManagement\Uninstall-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package]
, Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage


and


PS C:\Windows\system32> Remove-Module -Name "SQLPS"
Remove-Module : No modules were removed. Verify that the specification of modules to remove is correct and those
modules exist in the runspace.
At line:1 char:1
+ Remove-Module -Name "SQLPS"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Remove-Module], InvalidOperationException
+ FullyQualifiedErrorId : Modules_NoModulesRemoved,Microsoft.PowerShell.Commands.RemoveModuleCommand


From what I can tell online, remove-module needs quotes while uninstall-module does not.


Please advise and thanks!

1 Reply
SQLPS and SQLServer are two indepndent modules.

SQLPS is the (legacy) module used by SQL Agent when running Job Steps that use the PowerShell subsytem (well, unless one uses the #NOSQLPS).

So, to answer your questions:
- No, it is not advised to uninstall SQLPS module (you would break SQL Agent)
- Yes, just use the -AllowClobber when installing SQLServer
- Do not (try to) Remove-Module SQLPS