Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install both SQLPS and SqlServer PowerShell module on Windows 10?

C:>$PSVersionTable.PSVersion.ToString() 5.1.18362.145

When I use Install-Module -Name SqlServer, it reports:

C:>Install-Module -Name SqlServer
PackageManagement\Install-Package : The following commands are already available on this system:'Decode-SqlName,Encode-SqlName,SQLSERVER:,Add-SqlAvailabilityData
base,Add-SqlAvailabilityGroupListenerStaticIp,Add-SqlFirewallRule,Backup-SqlDatabase,ConvertFrom-EncodedSqlName,ConvertTo-EncodedSqlName,Convert-UrnToPath,Disabl
e-SqlAlwaysOn,Enable-SqlAlwaysOn,Get-SqlCredential,Get-SqlDatabase,Get-SqlInstance,Get-SqlSmartAdmin,Invoke-PolicyEvaluation,Invoke-Sqlcmd,Join-SqlAvailabilityGr

Yes, those appear to be from the SQLPS module. Is it not possible to have two (2) modules with the same exported names?

Update:

Ok, -AllowClobber did avoid the error message. But now I appear to have commands available from both SqlServer and SQLPS.

C:>get-command -Sql

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Decode-SqlName                                     21.1.18121 SqlServer
Alias           Decode-SqlName                                     14.0       SQLPS
Alias           Encode-SqlName                                     21.1.18121 SqlServer
Alias           Encode-SqlName                                     14.0       SQLPS
Cmdlet          Add-SqlAvailabilityDatabase                        21.1.18121 SqlServer
Cmdlet          Add-SqlAvailabilityDatabase                        14.0       SQLPS

But, using Get-Command in a different way, only shows commands from the SqlServer module.

C:>Get-Command Get-Sqli*

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-SqlInstance                                    21.1.18121 SqlServer
Cmdlet          Get-SqlInstance                                    14.0       SQLPS


C:>Get-Command Get-SqlInstance

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-SqlInstance                                    21.1.18121 SqlServer
like image 763
lit Avatar asked Nov 06 '22 16:11

lit


1 Answers

You can:

Install-Module ... -AllowClobber

to override this error, possibly combined with

-Scope CurrentUser

To only install for a single user.

Or you can install Powershell Core to create a seperate powershell environment for the other module.

like image 144
David Browne - Microsoft Avatar answered Nov 12 '22 15:11

David Browne - Microsoft