Skip to content

System32 module path is added repeatedly in subprocesses #7327

@rjmholt

Description

@rjmholt

Steps to reproduce

> $env:PSModulePath -split ';'
C:\Users\roholt\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

> & "$PSHOME\pwsh.exe"
> $env:PSModulePath -split ';'
C:\Users\roholt\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

> & "PSHOME\pwsh.exe"
> $env:PSModulePath -split ';'
C:\Users\roholt\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

> exit
> $env:PSModulePath -split ';'
C:\Users\roholt\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

> exit
> $env:PSModulePath -split ';'
C:\Users\roholt\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

Expected behavior

System32 module paths don't build up.

Actual behavior

System32 module paths keep getting tacked onto the end of the the PSModulePath.

Pros:

  • You always know how many PowerShells deep you are

Cons:

  • This is broken

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.4
PSEdition                      Core
GitCommitId                    6.1.0-preview.4
OS                             Microsoft Windows 10.0.18200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions