The Install-Module command installs or updates modules from the PowerShell Gallery or any other configured repository. By default, Install-Module adds modules to the path for AllUsers, at C:Program FilesWindowsPowerShellModules.
Installing a module under the AllUsers scope requires an administrator account.
For example, the posh-git module may be installed using either of the following two commands:
Find-Module posh-git | Install-Module Install-Module posh-git
Modules may be installed under a user-specific path ($homeDocumentsWindowsPowerShellModules) using the Scope parameter:
Install-Module carbon -Scope CurrentUser
If the most recent version of a module is already installed, the command ends without providing feedback.
In Windows PowerShell, if a newer version is available, it will be automatically installed alongside the original.
In PowerShell Core, a warning is displayed, indicating that the Force parameter must be used to install a newer version, such as in the following example:
Install-Module carbon -Scope CurrentUser -Force
Force may be used to re-install a module in both Windows PowerShell and PowerShell Core:
Install-Module posh-git -Force
The Install-Module command does not provide an option to install modules under the $PSHOME ($env:SYSTEMROOTSystem32WindowsPowerShellv1.0) directory. The $PSHOME path is reserved for modules created by Microsoft that are deployed with the Windows Management Framework (WMF) or the Windows operating system.