Install Module - PowerShell


Overview

Install-Module installs PowerShell modules from the PowerShell Gallery or a local path. PowerShell modules are reusable packages containing commands, functions, scripts, and other resources that extend PowerShell’s capabilities.

Syntax

Install-Module [-Name] <ModuleName> [-RequiredVersion <Version>] [-Scope <Scope>] [-FromSource <Source>] [-Force] [-AllowClobber] [-AllowPrerelease] [-SkipPublisherCheck] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ThrottleLimit <Int>] [-WhatIf] [-Confirm] [-PassThru]

Options/Flags

  • -Name: Specifies the name of the module to install.
  • -RequiredVersion: Specifies the minimum required version of the module.
  • -Scope: Specifies the installation scope (CurrentUser or AllUsers).
  • -FromSource: Specifies the path to a local module file.
  • -Force: Overwrites existing modules with the same name.
  • -AllowClobber: Overwrites conflicting files during installation.
  • -AllowPrerelease: Allows the installation of prerelease modules.
  • -SkipPublisherCheck: Skips the check for trusted publishers.
  • -Proxy: Specifies a proxy server.
  • -ProxyCredential: Specifies a credential for proxy authentication.
  • -ThrottleLimit: Limits the number of simultaneous downloads.
  • -WhatIf: Simulates the installation without making any changes.
  • -Confirm: Prompts for confirmation before installing.
  • -PassThru: Returns the installed module object.

Examples

Install a module from the PowerShell Gallery:

Install-Module PSReadLine

Install a specific version of a module:

Install-Module -Name PSReadLine -RequiredVersion 2.2.1

Install a module from a local path:

Install-Module -FromSource "C:\MyModules\MyModule.psm1"

Force overwrite an existing module:

Install-Module -Name PSReadLine -Force

Common Issues

  • Module not found: Ensure the module name is correct and that the module is published in the PowerShell Gallery.
  • Access denied: Check permissions on the installation path and ensure the user has sufficient privileges.
  • Module dependency not met: Install any required dependencies before installing the module.

Integration

  • Combine with Find-Module to search for modules.
  • Use with Import-Module to load the installed module.
  • Automate module installation using scripts or pipelines.
  • Get-Module
  • Remove-Module
  • Update-Module

PowerShell Gallery