How PsGet decides where to install modules
Clone this wiki locally
When importing a module, PowerShell refers to an environment variable named PSModulePath which is a list of directories containing PowerShell modules. PowerShell will search through these directories in the order that they are listed in the PSModulePath variable.
The default value of the PSModulePath variable contains two entries, the first refers to the current user's Modules path under their profile's My Documents folder, the second path refers to the system Modules path under the PowerShell installation folder. For example, for a user named "Mike" on Windows 7, the default value may be:
When installing a module with PsGet it also follows some basic rules to determine which folder to put the module in. Here they are in order:
- If the Install-Module cmdlet's -Destination parameter is specified with a path, it is used.
- If the $PsGetDestinationModulePath variable has been set to a path, it is used.
- If the Install-Module cmdlet's -Global switch has been specified, and the PSModulePath variable contains an entry referring to the system Modules path, that path will be used. Note: elevated administrator privileges are required to install modules to this location.
- If the PSModulePath variable contains an entry referring to the current user's Module path, that path will be used.
- If none of the above conditions are met, the first entry in the PSModulePath variable is used.