Powershell:- Modules – sqlServer – Install

Background

A few posts back spoke about trying to get a Vendor Script working.

We will need to install the Powershell SQLServer module, as well.

 

Timeline

  1. Win OS:- IIS Management Tools ( web-mgmt-console ) install
    Link

 

Errors

Here is the error message.

Error Message – “The SQLServer powershell is not installed”

Image

Textual


Checking that required modules are installed...FAILED
The SQLServer powershell module is not installed. Please install SQL Server powershell tools before continuing.

Remediation

Let us go install the SQLServer powershell module.

Install

Outline

  1. Install SQLServer Powershell module
    • sqlServer
  2. Inquire SQL Server Powershell module
    • sqlServer

Install Powershell SQL Server Module

sqlServer – No Additional Option

Syntax

powershell -Command "Install-Module -Name SqlServer"

Sample

powershell -Command "Install-Module -Name sqlServer"

Output – Installing
Output – Image

Output – Installation – Failed – Image
Image
Output – Installation Failed – Textual
>powershell -Command "Install-Module -Name SqlServer"

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PackageManagement\Install-Package : The following commands are already available on this system:'Add-SqlAvailabilityDat
abase,Add-SqlAvailabilityGroupListenerStaticIp,Add-SqlFirewallRule,Backup-SqlDatabase,ConvertFrom-EncodedSqlName,Conver
tTo-EncodedSqlName,Convert-UrnToPath,Disable-SqlAlwaysOn,Enable-SqlAlwaysOn,Get-SqlCredential,Get-SqlDatabase,Get-SqlIn
stance,Get-SqlSmartAdmin,Invoke-PolicyEvaluation,Invoke-Sqlcmd,Join-SqlAvailabilityGroup,New-SqlAvailabilityGroup,New-S
qlAvailabilityGroupListener,New-SqlAvailabilityReplica,New-SqlBackupEncryptionOption,New-SqlCredential,New-SqlHADREndpo
int,Remove-SqlAvailabilityDatabase,Remove-SqlAvailabilityGroup,Remove-SqlAvailabilityReplica,Remove-SqlCredential,Remov
e-SqlFirewallRule,Restore-SqlDatabase,Resume-SqlAvailabilityDatabase,Save-SqlMigrationReport,Set-SqlAuthenticationMode,
Set-SqlAvailabilityGroup,Set-SqlAvailabilityGroupListener,Set-SqlAvailabilityReplica,Set-SqlCredential,Set-SqlHADREndpo
int,Set-SqlNetworkConfiguration,Set-SqlSmartAdmin,Start-SqlInstance,Stop-SqlInstance,Suspend-SqlAvailabilityDatabase,Sw
itch-SqlAvailabilityGroup,Test-SqlAvailabilityGroup,Test-SqlAvailabilityReplica,Test-SqlDatabaseReplicaState,Test-SqlSmartAdmin'. 

This module 'SqlServer' may override the existing commands. If you still want to install this module
'SqlServer', use -AllowClobber parameter.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
ageManagement.Cmdlets.InstallPackage

Explanation
  1. This module ‘SqlServer’ may override the existing commands. If you still want to install this module ‘SqlServer’, use -AllowClobber parameter.

sqlServer – Option – AllowClobber

Outline
  1. Options
    • AllowClobber
      • Allows the import of members that have the same names as members that are already installed
Syntax

powershell -Command "Install-Module -Name SqlServer -AllowClobber"

Sample

powershell -Command "Install-Module -Name sqlServer -AllowClobber"

Output – Installing
Output – Image

 

Inquire Powershell Module Installed

Powershell – Module – sqlServer – Display output as text

Syntax

powershell -Command "Get-InstalledModule"

Sample

powershell -Command "Get-InstalledModule -name 'sqlserver' "

Output
Output – Image

Output – Textual
 

>powershell "Get-InstalledModule -Name 'SQLServer' "

Version       Name      Repository Description
-------         ---            ---------- -----------
21.1.18256 SqlServer PSGallery This module allows SQL Server developers, administrators and business intelligence professionals to automate database development and server administration, as well ...

Explanation

Here is the status of our installation

  1. Version
    • 21.1.18256
  2. Name
    • SqlServer
  3. Repository
    • PSGallery
  4. Description
    • This module allows SQL Server developers, administrators and business intelligence professionals to automate database development and server administration, as well …

Powershell – Module – sqlServer – Display output as grid

Syntax

powershell -Command "Get-InstalledModule -Name '<feature>' | Out-GridView -Wait"

Sample

powershell -Command "Get-InstalledModule -Name 'SQLServer' | Out-GridView -Wait"

Output
Output – Image

Explanation

Here is the status of our installation

  1. Version
    • 21.1.18256
  2. Name
    • SqlServer
  3. Repository
    • PSGallery
  4. Description
    • This module allows SQL Server developers, administrators, and business intelligence professionals to automate database development and server administration, as well …

Summary

We  _uck with PowerShell as it actually makes our day fun!

 

Referenced Work

  1. Microsoft
    • Docs
      • Docs > PowerShell > Scripting > Reference > Microsoft.PowerShell.Core > Import-Module
        Link
      • Docs > PowerShell > Scripting > Reference > PowerShellGet > Get-InstalledModule
        Link
      • Docs > PowerShell > Scripting > Reference > Microsoft.PowerShell.Utility > Out-GridView
        Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s