Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change where a Powershell module is installed?

Tags:

powershell

I am using version 3.0 and there doesn't seem to be a way to specify a default folder where all your modules are installed. In particular, I am trying to install Posh-Git, but it insists on installing the modules in MyDocuments\WindowsPowershell. How do I change this?

like image 470
ATL_DEV Avatar asked Nov 04 '12 00:11

ATL_DEV


People also ask

How do I change the path of a PowerShell module?

To add or change files in the $env:Windir\System32 directory, start PowerShell with the Run as administrator option. You can change the default module locations on your system by changing the value of the PSModulePath environment variable, $Env:PSModulePath .

How do I install a PowerShell module from a specific path?

You can determine where to install your module using one of the paths stored in the $ENV: PSModulePath variable. To do this, open a PowerShell window and run the command: $Env: PSModulePath. The output displays the following path as shown in Figure 3.0 below: C:\Users\Administrator\Documents\WindowsPowerShell\Modules.

How do I find the path of a PowerShell module?

How can I easily find the path to a Windows PowerShell module? Use the Get-Module cmdlet and a wildcard character for the name, and select the Path property.

Where do I put custom PowerShell modules?

The paths where you can install your module are located in the $env:PSModulePath global variable. For example, a common path to save a module on a system would be %SystemRoot%/users/<user>/Documents/PowerShell/Modules/<moduleName> .


1 Answers

By default, PowerShell looks for modules in one of two locations, both are specified in the PSModulePath environment variable.

   System modules: %windir%\System32\WindowsPowerShell\v1.0\Modules
   Current user modules:  %UserProfile%\Documents\WindowsPowerShell\Modules

You can add your own module directory to the path:

$env:PSModulePath+=';c:\MyModules'
like image 111
Shay Levy Avatar answered Oct 04 '22 20:10

Shay Levy