Skip to content

Calling powershell.exe in PSCore6 on Windows starts Windows PowerShell #4194

Closed

Description

@SteveL-MSFT

On Windows, $env:Path has Windows PowerShell in the path before $PSHOME which means that if you're in PowerShell Core 6 and type powershell, it starts Windows PowerShell 5.1 instead of a nested instance of PowerShell Core 6. This may be unexpected for end users as it seems that one would expect powershell to refer to the currently running version of PowerShell.

The immediate impact is that partner teams running existing PowerShell script tests in PowerShell Core 6 that spawn powershell will get incorrect results as that process is running Windows PowerShell.

cc Joey Aiello (@joeyaiello) Hemant Mahawar (@HemantMahawar)

Steps to reproduce

# within PowerShell Core 6
powershell
$psversiontable

Expected behavior

PowerShell Core 6

Actual behavior

Windows PowerShell 5.1

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.3
OS                             Microsoft Windows 10.0.16225
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. iSazonov commented on Jul 6, 2017

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) Maybe Area-SideBySide?

  2. iSazonov commented on Jul 6, 2017

    @iSazonov
    Collaborator

    If we have some PowerShell versions on system we should think about "default PowerShell" and a way to run specific PowerShell version by -Version parameter.
    A rule may be "By default Windows PowerShell run Windows PowerShell, PowerShell Core run PowerShell Core".

  3. added
    Area-SideBySide
    and removed
    WG-Interactive-Console
    on Jul 6, 2017
  4. added this to the milestone on Jul 6, 2017
  5. SteveL-MSFT commented on Jul 6, 2017

    @SteveL-MSFT
    MemberAuthor

    Based on some internal discussions, I think we agree that on Windows, we should put $PSHOME first in $env:PATH rather than at the end.

  6. iSazonov commented on Jul 7, 2017

    @iSazonov
    Collaborator

    What about to enhance -Version?

    powershell -Version 5.1
    powershell -Version 6.0.0
    powershell -Version 6.0.0-Beta.4
    powershell -Version UserDefault
    powershell -Version SystemDefault
  7. SteveL-MSFT commented on Jul 7, 2017

    @SteveL-MSFT
    MemberAuthor

    Ilya (@iSazonov) I think you should open a separate issue to discuss that

  8. iSazonov commented on Jul 7, 2017

    @iSazonov
    Collaborator

    Done #4199

  9. joeyaiello commented on Jul 10, 2017

    @joeyaiello
    Contributor

    Steve Lee (@SteveL-MSFT): other implications of this worry me. E.g. it might mean that anyone who can write to $PSHome can now squat over system binaries from within PowerShell. Let's talk offline.

  10. MaximoTrinidad commented on Jul 10, 2017

    @MaximoTrinidad

    In my own opinion, we should kept then separately. As soon the PowerShell Core installation overrides any of the existing Windows variables over the Windows PowerShell it could open issues across the board.

    :)

  11. SteveL-MSFT commented on Jul 13, 2017

    @SteveL-MSFT
    MemberAuthor

    Joey Aiello (@joeyaiello) PSCore6 implicitly trusts binaries in $PSHome so that folder needs to be secure regardless. The only change being proposed here is to move $PSHome to front of $env:Path (at the process level, not system or user setting) instead of the end so that it takes precedence over Windows PowerShell path.

  12. SteveL-MSFT commented on Jul 13, 2017

    @SteveL-MSFT
    MemberAuthor

    If we decide to do #4214, we don't need to address this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-SideBySideOS-WindowsResolution-Fixed

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions