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?
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 .
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 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.
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> .
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With