简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM