Normal Installation

To install an external PowerShell module (for example, SQLServer):

Install-Module -Name SqlServer

Manual Installation

How to get the location to copy a PowerShell module?

$env:PSModulePath
  • To copy a PowerShell module, follow these steps (administrator right):
    • Go to the PowerShell Gallery at https://www.powershellgallery.com/packages/Sqlserver and download the .nupkg file.
    • Extract the contents of the downloaded .nupkg file using 7-Zip or a similar tool.
    • After extraction, rename the folder “sqlserver.21.1.18256” to “sqlserver”.
    • Copy the “sqlserver” folder to the following directory: “C:\Program Files\WindowsPowerShell\Modules”. If the “Modules” folder does not exist, create it before copying.

Use the powershell module

To use the module, type the command:

import-module SqlServer

After installing the module, you can use it, for example:

Invoke-Sqlcmd -ServerInstance $Instance -Database $Bdd  -Username $CompteSQL -Password $PassSQL -InputFile $FileSQL

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.