Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ private void ParseHelper(string[] args)
_noInteractive = true;
_skipUserInit = true;
_noExit = false;

++i;
if (i < args.Length)
{
WriteCommandLineError(string.Format(CultureInfo.CurrentCulture, CommandLineParameterParserStrings.DeprecatedVersionParameter,args[i]));
}
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,7 @@ EXAMPLES
<data name="InvalidArgument" xml:space="preserve">
<value>Invalid argument '{0}', did you mean:</value>
</data>
<data name="DeprecatedVersionParameter" xml:space="preserve">
<value>Usage of '-Version {0}' is not supported. '-Version' currently only returns the current PowerShell version.</value>
</data>
</root>
9 changes: 9 additions & 0 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
$observed | should be $currentVersion
}

It "-Version should write an error if a value is present" {
$versionValue = "abrakadabra"
$tempFile = Join-Path $testdrive "expectedError.txt"
$observed = & $powershell -version $versionValue > $tempFile
$expectedError = (Get-Content $tempFile)[0]

$expectedError | Should Match $versionValue
}

It "-File should be default parameter" {
Set-Content -Path $testdrive/test -Value "'hello'"
$observed = & $powershell -NoProfile $testdrive/test
Expand Down