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 commentaire

Laisser un commentaire

Emplacement de l’avatar

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.