Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PSModulePath inherited when calling powershell.exe from pwsh.exe #8863

Copy link
Copy link
@janegilring

Description

@janegilring
Issue body actions

This may be by design, but I wanted to make sure as it can lead to some unpredictable results when calling Windows PowerShell from PowerShell Core.

When calling powershell.exe (to run some command which is not available in PowerShell Core, such as Show-Command) - the PSModulePath environment variable seems to be inherited from pwsh.exe.

One example is calling Show-Command against a command which exists only in a PowerShell Core module (e.g. New-AzVm from C:\Program Files\PowerShell\Modules\Az.Compute):
powershell.exe -noprofile 'Show-Command New-AzVm'

This should not have worked since Az.Compute is only installed in PowerShell Core, and not available in any of the PSModule paths for Windows PowerShell (on my machine).

This is a trivial example, but could have lead to more unpredictable results if a PowerShell Core-only module was called in a Windows PowerShell runspace.

Steps to reproduce

# From pwsh.exe on Windows
powershell.exe -noprofile '$env:psmodulepath'

Expected behavior

C:\Users\janring\Documents\WindowsPowerShell;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

Actual behavior

C:\Users\janring\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\6\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

Environment data

Name                           Value
----                           -----
PSVersion                      6.1.2
PSEdition                      Core
GitCommitId                    6.1.2
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.Resolution-DuplicateThe issue is a duplicate.The issue is a duplicate.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.