You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I know, PowerShell v2 was recently declared deprecated.
Thus, it normal to expect some kind of related errors in the latest v6.
The behaviour is strange, though. If I try to invoke something (anything
actually, including gibberish) with -version 2 then PowerShell succeeds
($LASTEXITCODE is 0) and prints the same result powershell v6.0.0-beta.7.
Steps to reproduce
powershell -version 2 gibberish
$LASTEXITCODE
Expected behavior
Non-zero $LASTEXITCODE and a clear error message.
Actual behavior
Zero $LASTEXITCODE and some version-like text, the same regardless of a command.
powershell v6.0.0-beta.7
0
Environment data
PowerShell-6.0.0-beta.7-win-x64.zip
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.7
OS Microsoft Windows 10.0.10586
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Since PSCore6 is inherently side-by-side, you can start different versions using file paths, so currently -version only emits the version info. Although perhaps we should error if anything else is passed after the arg. We can use this issue to track returning an error so that the result is not confusing for Windows PowerShell users.
If now -version show PowerShell Core version of started exe we could introduce -versions to show all discovered (by paths? config files?) PowerShell versions and -versions <vername> to start the specific version.
Although perhaps we should error if anything else is passed after the arg. We can use this issue to track returning an error so that the result is not confusing for Windows PowerShell users.
Yes, please. It currently confuses users, including some relatively experienced :)
Updated title. The committee has discussed ways to enumerate installed versions and starting them easily, but that discussion should be a different issue.
With #4958, we will be adopting the behavior of other popular cmdline tools like git, curl, bash where -v outputs the version and ignores the rest of the cmdline
The conclusion is that we don't write an error for -Version 2.0. We have plans to implement new side-by-side behavior to run other PowerShell versions and will document this (in docs and Release Notes).
Activity
SteveL-MSFT commentedon Sep 14, 2017
This is a change we took awhile back with #3115
Since PSCore6 is inherently side-by-side, you can start different versions using file paths, so currently
-versiononly emits the version info. Although perhaps we should error if anything else is passed after the arg. We can use this issue to track returning an error so that the result is not confusing for Windows PowerShell users.iSazonov commentedon Sep 14, 2017
If now
-versionshow PowerShell Core version of started exe we could introduce-versionsto show all discovered (by paths? config files?) PowerShell versions and-versions <vername>to start the specific version.nightroman commentedon Sep 14, 2017
Steve Lee (@SteveL-MSFT) Thank you for the clarification.
Yes, please. It currently confuses users, including some relatively experienced :)
[-]v6-beta.7 - strange result on trying to invoke with -Version 2[/-][+]powershell -version 2 should return error[/+]SteveL-MSFT commentedon Sep 14, 2017
Updated title. The committee has discussed ways to enumerate installed versions and starting them easily, but that discussion should be a different issue.
iSazonov commentedon Sep 14, 2017
Steve Lee (@SteveL-MSFT) Do you ask me to open new Issue "Enumerate installed PowerShell versions"?
SteveL-MSFT commentedon Sep 14, 2017
Ilya (@iSazonov) I didn't find an existing issue, so please open a new one. Thanks!
iSazonov commentedon Sep 14, 2017
Done #4836
SteveL-MSFT commentedon Oct 2, 2017
With #4958, we will be adopting the behavior of other popular cmdline tools like git, curl, bash where
-voutputs the version and ignores the rest of the cmdlineiSazonov commentedon Oct 3, 2017
The conclusion is that we don't write an error for
-Version 2.0. We have plans to implement new side-by-side behavior to run other PowerShell versions and will document this (in docs and Release Notes).