PowerShell
PowerShell copied to clipboard
-NoProfile should not add Modules folder under the user profile in PSModulePath
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
- [X] Refer to the FAQ.
- [X] Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
- Start cmd
- Clear the environment variable PSModulePath
- Start pwsh.exe -noprofile
- Evaluate $env:PSModulePath
Expected behavior
PSModulePath should not include any path under the user profile.
Actual behavior
PSModulePath includes paths under the user profile.
Error details
N/A
Environment data
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.26236
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
N/A
Why shouldn't it include those modules? It's not unreasonable to think someone would want to skip loading the $profile script(s) while still having those modules available. It would be better to ask for a new switch if you think it's useful to exclude user scoped modules.
Agree, will it be possible to introduce a new flag -NoModulePath ?
Can you please explain the use case for this feature?