From bfbf9df866a61bf7194a98cdabc38c864168eb9f Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 7 Feb 2020 14:36:34 -0800 Subject: [PATCH] Update behavior of PSModulePath in PS7 --- .../About/about_Environment_Variables.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/reference/7.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md b/reference/7.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md index fc1758311f4d..5e99bbb8a501 100644 --- a/reference/7.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md +++ b/reference/7.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md @@ -252,7 +252,7 @@ The environment variables that store preferences include: The default value of `$Env:PSModulePath` on Windows is: ```powershell - $HOME\Documents\WindowsPowerShell\Modules;$PSHOME\Modules + $HOME\Documents\PowerShell\Modules;$env:PROGRAMFILES\PowerShell\Modules;$PSHOME\Modules ``` The default value of `$Env:PSModulePath` on Linux or macOS is: @@ -261,10 +261,14 @@ The environment variables that store preferences include: $HOME/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:$PSHOME/Modules ``` -PowerShell sets the value of `$PSHOME\Modules` in the registry. It sets the -value of `$HOME\Documents\PowerShell\Modules` each time you start PowerShell. +PowerShell will prefix the user module path, the shared module path, and the $PSHOME +module path to `PSModulePath` if it is not already in `PSModulePath`. -In addition, setup programs that install modules in other directories, such as +In addition, on Windows, if the inherited `PSModulePath` is the same as the one stored +as the user environment variable, then the machine `PSModulePath` environment variable +is appended to the end. + +Also, setup programs that install modules in other directories, such as the `Program Files` directory, can append their locations to the value of PSModulePath. @@ -323,6 +327,10 @@ You can add also add a command that changes the value to your profile or use System in Control Panel to change the value of the `PSModulePath` environment variable in the registry. +When starting Windows PowerShell or PowerShell ISE, PowerShell will remove the +version specific user module path, shared module path, and $PSHOME module path +from `PSModulePath` given to the child process. + For more information, see [about_Modules](about_Modules.md). ## SEE ALSO