PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

-NoProfile should not add Modules folder under the user profile in PSModulePath

Open ocalvo opened this issue 1 year ago • 3 comments

Prerequisites

Steps to reproduce

  1. Start cmd
  2. Clear the environment variable PSModulePath
  3. Start pwsh.exe -noprofile
  4. 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

ocalvo avatar Jun 14 '24 18:06 ocalvo

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.

MartinGC94 avatar Jun 14 '24 18:06 MartinGC94

Agree, will it be possible to introduce a new flag -NoModulePath ?

ocalvo avatar Jun 14 '24 19:06 ocalvo

Can you please explain the use case for this feature?

ThomasNieto avatar Jun 15 '24 05:06 ThomasNieto