Skip to content

Please Start Versioning PowerShell.exe (So The latest version can be found by Get-Command) #5166

Closed

Description

@DarwinJS

Can't do the following from openssh installer to find the latest powershell core.

get-command "c:\program files\PowerShell*\PowerShell.exe"

So the weird thing is to do the same thing for any other default shell candidate from third parties - this would likely work - to, for instance, find the latest bash.exe

I can do a work around by using the versioned folder for now - but that only handles the default install location where the methodology of a versioned folder is followed by convention. If someone drops it in another folder or I try get-command against the file unpathed - I won't find a version.

There are obviously a lot of other reasons this should be done - just giving light to a very practical and current scenario.

Activity

  1. iSazonov commented on Oct 19, 2017

    @iSazonov
    Collaborator

    It seems dup #4836 - we can discuss there.

  2. DarwinJS commented on Oct 19, 2017

    @DarwinJS
    ContributorAuthor

    It is not really a duplicate - getting a version number to compile into the PE header should be a couple compiler settings. Additionally, you could have an exe emit it's version without coding the PE header.

    Both ways should be probably enabled, but importantly, the PE header can be examined without running the EXE.

  3. SteveL-MSFT commented on Oct 20, 2017

    @SteveL-MSFT
    Member

    #4836 is different. I think I can take care of this one and the icon one at the same time.

  4. iSazonov commented on Oct 21, 2017

    @iSazonov
    Collaborator

    The issue for Windows only. If we'll think about portability it is better to be based on SMA.dll to get a version by Get-Command.

  5. SteveL-MSFT commented on Oct 21, 2017

    @SteveL-MSFT
    Member

    Darwin (@DarwinJS) what Ilya (@iSazonov) has found is that SMA.dll has file version information already with PSCore6 even on non-Windows. Since that is a core dll that will always be there with PowerShell, you can rely on it (with the exception of Windows PowerShell where SMA.dll is in the GAC and not in $PSHOME)

  6. DarwinJS commented on Oct 21, 2017

    @DarwinJS
    ContributorAuthor

    I appreciate the tip. It would be great if it could be right in the EXEs like you all did with openssh.

    For instance, I was working on the ability for the openssh package to probe for which exe to use for the DefaultShell. By the time I got it done, I realized I would need to make sure they can only choose an EXE and should not be allowed to have any wildcards in the file name so that they are always going for a know file name and don't pickup unintention EXEs.

    Just wanted to give light to a use case where having it actually in the exe is not only what is generally expected on Windows - in this case it avoids custom code to go find the version for an EXE by looking in a DLL.

    Is it somehow more challenging to do it for powershell than it was for openssh?

  7. SteveL-MSFT commented on Oct 21, 2017

    @SteveL-MSFT
    Member

    Darwin (@DarwinJS) I have a PR opened for pwsh.exe on Windows, Ilya (@iSazonov)'s comment is that checking the version of pwsh.exe only works on Windows while checking version of SMA.dll works on all platforms.

  8. DarwinJS commented on Oct 21, 2017

    @DarwinJS
    ContributorAuthor

    Steve Lee (@SteveL-MSFT) - thanks for clarifying! I was thinking it was being offered as a permanent alternative.

  9. iSazonov commented on Oct 22, 2017

    @iSazonov
    Collaborator

    I found SMA.dll idea in VS Code repo - they use that to enumerate PowerShells on all platforms.

  10. added a commit that references this issue on Oct 27, 2017
    4df7036
  11. added a commit that references this issue on Aug 6, 2026
    9e0434e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution-FixedWG-Maintainers-Build

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions