diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
index 18632f22ab7..ff02a8dbb29 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs
@@ -400,15 +400,9 @@ internal bool NonInteractive
private void ShowHelp()
{
+ Dbg.Assert(_helpText != null, "_helpText should not be null");
_hostUI.WriteLine("");
- if (_helpText == null)
- {
- _hostUI.WriteLine(CommandLineParameterParserStrings.DefaultHelp);
- }
- else
- {
- _hostUI.Write(_helpText);
- }
+ _hostUI.Write(_helpText);
_hostUI.WriteLine("");
}
@@ -548,17 +542,9 @@ 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;
}
-
-
- if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
+ else if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?"))
{
_showHelp = true;
_abortStartup = true;
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index 84e9cf33845..cb1bd8992ba 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -200,7 +200,7 @@ internal static int Start(
// Alternatively, we could call s_theConsoleHost.UI.WriteLine(s_theConsoleHost.Version.ToString());
// or start up the engine and retrieve the information via $psversiontable.GitCommitId
// but this returns the semantic version and avoids executing a script
- s_theConsoleHost.UI.WriteLine("powershell " + PSVersionInfo.GitCommitId);
+ s_theConsoleHost.UI.WriteLine("PowerShell " + PSVersionInfo.GitCommitId);
return 0;
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx
index 19627b9271c..7ad30993383 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx
+++ b/src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx
@@ -129,89 +129,6 @@
Unrecognized parameter: '{0}'.
-
- PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
- [-NoLogo] [-NoExit] [-NoProfile] [-NonInteractive] [-STA]
- [-OutputFormat {Text | XML}] [-InputFormat {Text | XML}]
- [-ConfigurationName <string>]
- [-File fileName [arguments...]] [-ExecutionPolicy <ExecutionPolicy>]
- [-Command { - | <script-block> [-args <arg-array>]
- | <string> [<CommandParameters>] } ]
-
-PowerShell[.exe] -Help | -? | /?
-
--PSConsoleFile
- Loads the specified PowerShell console file. To create a console
- file, use Export-Console in PowerShell.
-
--Version
- Starts the specified version of PowerShell.
-
--NoLogo
- Hides the copyright banner at startup.
-
--NoExit
- Does not exit after running startup commands.
-
--NoProfile
- Does not use the user profile.
-
--NonInteractive
- Does not present an interactive prompt to the user.
-
--STA
- Uses a single-threaded apartment for the execution thread.
-
--OutputFormat
- Determines how output from PowerShell is formatted. Valid values
- are "Text" (text strings) or "XML" (serialized CLIXML format).
-
--InputFormat
- Describes the format of data sent to PowerShell. Valid values are
- "Text" (text strings) or "XML" (serialized CLIXML format).
-
--ConfigurationName
- Specifies a configuration endpoint in which PowerShell is run.
- This can be any endpoint registered on the local machine including the
- default PowerShell remoting endpoints or a custom endpoint having
- specific user role capabilities.
-
--Command
- Executes the specified commands (and any parameters) as though they were
- typed at the PowerShell command prompt, and then exits, unless
- NoExit is specified. The value of Command can be "-", a string. or a
- script block.
-
- If the value of Command is "-", the command text is read from standard
- input.
-
- Script blocks must be enclosed in braces ({}). You can specify a script
- block only when running PowerShell.exe in PowerShell. The results
- of the script are returned to the parent shell as deserialized XML objects,
- not live objects.
-
- If the value of Command is a string, Command must be the last parameter
- in the command , because any characters typed after the command are
- interpreted as the command arguments.
- To write a string that runs a PowerShell command, use the format:
- "& {<command>}"
- where the quotation marks indicate a string and the invoke operator (&)
- causes the command to be run.
-
--Help, -?, /?
- Shows this message. If you are typing a PowerShell.exe command in Windows
- PowerShell, prepend the command parameters with a hyphen (-), not a forward
- slash (/). You can use either a hyphen or forward slash in Cmd.exe.
-
-
-EXAMPLES
- PowerShell -PSConsoleFile SqlSnapin.Psc1
- PowerShell -version 1.0 -NoLogo -InputFormat text -OutputFormat XML
- PowerShell -ConfigurationName AdminRoles
- PowerShell -Command {Get-EventLog -LogName security}
- PowerShell -Command "& {Get-EventLog -LogName security}"
-
-
'-' was specified with the -Command parameter; no other arguments to -Command are permitted.
@@ -272,7 +189,4 @@ EXAMPLES
Invalid argument '{0}', did you mean:
-
- Usage of '-Version {0}' is not supported. '-Version' currently only returns the current PowerShell version.
-
diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx
index 912656e069d..a40c9d4b1ce 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx
+++ b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx
@@ -122,8 +122,8 @@
Copyright (C) Microsoft Corporation. All rights reserved.
- PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
- [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive] [-Interactive]
+ PowerShell[.exe] [-Version] [-NoLogo] [-NoExit]
+ [-NoProfile] [-NonInteractive] [-Interactive]
[-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
[-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
[-ConfigurationName <string>]
@@ -133,13 +133,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
PowerShell[.exe] -Help | -? | /?
--PSConsoleFile
- Loads the specified PowerShell console file. To create a console
- file, use Export-Console in PowerShell.
-
-Version
- Starts the specified version of PowerShell.
- Enter a version number with the parameter, such as "-version 2.0".
+ Shows the version of PowerShell and exits.
+ Additional arguments are ignored.
-NoLogo
Hides the copyright banner at startup.
@@ -147,13 +143,6 @@ PowerShell[.exe] -Help | -? | /?
-NoExit
Does not exit after running startup commands.
--Sta
- Starts the shell using a single-threaded apartment.
- Single-threaded apartment (STA) is the default.
-
--Mta
- Start the shell using a multithreaded apartment.
-
-NoProfile
Does not load the PowerShell profile.
@@ -228,8 +217,7 @@ PowerShell[.exe] -Help | -? | /?
slash (/). You can use either a hyphen or forward slash in Cmd.exe.
EXAMPLES
- PowerShell -PSConsoleFile SqlSnapIn.Psc1
- PowerShell -version 2.0 -NoLogo -InputFormat text -OutputFormat XML
+ PowerShell -Version
PowerShell -ConfigurationName AdminRoles
PowerShell -Command {Get-EventLog -LogName security}
PowerShell -Command "& {Get-EventLog -LogName security}"
@@ -239,6 +227,6 @@ EXAMPLES
$command = 'dir "c:\program files" '
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
- powershell.exe -encodedCommand $encodedCommand
+ powershell -encodedCommand $encodedCommand
diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1
index 930e33c00cc..023e8e94f6f 100644
--- a/test/powershell/Host/ConsoleHost.Tests.ps1
+++ b/test/powershell/Host/ConsoleHost.Tests.ps1
@@ -165,26 +165,15 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
$actual | Should Be $expected
}
- It "-Version should return the engine version" {
- $currentVersion = "powershell " + $PSVersionTable.GitCommitId.ToString()
- $observed = & $powershell -version
- $observed | should be $currentVersion
- }
-
- It "-Version should ignore other parameters" {
+ It "-Version should return the engine version using: -version " -TestCases @(
+ @{value = ""},
+ @{value = "2"},
+ @{value = "-command 1-1"}
+ ) {
$currentVersion = "powershell " + $PSVersionTable.GitCommitId.ToString()
- $observed = & $powershell -version -command get-date
- # no extraneous output
+ $observed = & $powershell -version $value 2>&1
$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
+ $LASTEXITCODE | Should Be 0
}
It "-File should be default parameter" {