Windows PowerShell inherits PSModulePath from PowerShell Core
See original GitHub issueIf you start Windows PowerShell from PowerShell Core, you get the $env:PSModulePath
from PowerShell Core.
In my opinion, this should be a 6.0.0
blocker. Also, if any work needs to be done in Windows PowerShell to fix this, we should do it ASAP.
Steps to reproduce
From PowerShell Core:
Start-Process powershell
This will open a new instance of Windows PowerShell. From this instance:
$env:PSModulePath
Expected behavior
C:\Users\jaiello\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
Also, PSReadline should load.
Actual behavior
C:\Users\jaiello\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\6.0.0.12\Modules
Also, PSReadline doesn’t load because it can’t be found.
Environment data
For PowerShell Core:
Name Value
---- -----
PSVersion 6.0.0-alpha
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
GitCommitId v6.0.0-alpha.12
CLRVersion
BuildVersion 3.0.0.0
PSRemotingProtocolVersion 2.3
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
For Windows PowerShell;
Name Value
---- -----
PSVersion 5.1.14931.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14931.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
about PSModulePath - PowerShell
The PSModulePath environment variable contains a list of folder locations that are searched to find modules and resources.
Read more >PowerShell Core doesn't inherit PSModulePath ...
Windows PowerShell correctly inherits environment variables from the environment -- although it may add paths to these variables, it doesn't ...
Read more >How does PSModulePath environment property get ...
Basically the root of the evil is that when I open a desktop Powershell and check $env:PSModulePath I see PS.Core module path there....
Read more >Inheritance in PowerShell Classes - SAPIEN Information Center
PowerShell classes can inherit from only one base class, so you can't specify more than one class name. (The class can implement multiple ......
Read more >Set PSModulePath Environment Variable with PowerShell ...
PowerShell - Get OS Environmental Variables without Expanding. You can use the Get-Item cmdlet with the -path parameter and then pass that ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Agree with @iSazonov this is
by-design
as child processes are expected to inherit environment from parent. The way to address this may be to have PSModulePath in https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0015-PowerShell-StartupConfig.mdIt is expected because subprocess always inherits environment variables of parent process. If we change the default behavior it can confuse users. We would backup
PSModulePath
on startup and restore before create subprocess. Or create$env:PSModulePath_Backup
and check it on PowerShell startup. The second is seems easier.