From adbf757c2ec3de3405ead903d0fab3cb5551d46e Mon Sep 17 00:00:00 2001 From: iSazonov Date: Tue, 3 Oct 2017 17:44:42 +0300 Subject: [PATCH 1/4] Reformat command line help for powershell -Help - sort parameter list in alphabetical order - replace long header on powershell[.exe] [options] - add examples --- .../resources/ManagedEntranceStrings.resx | 172 +++++++++--------- 1 file changed, 87 insertions(+), 85 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx index a40c9d4b1ce..24a589ce209 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx +++ b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx @@ -122,111 +122,113 @@ Copyright (C) Microsoft Corporation. All rights reserved. - PowerShell[.exe] [-Version] [-NoLogo] [-NoExit] - [-NoProfile] [-NonInteractive] [-Interactive] - [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}] - [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>] - [-ConfigurationName <string>] - [-Command { - | <script-block> [-args <arg-array>] - | <string> [<CommandParameters>] } ] - [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>] - -PowerShell[.exe] -Help | -? | /? - --Version - Shows the version of PowerShell and exits. - Additional arguments are ignored. - --NoLogo - Hides the copyright banner at startup. + PowerShell[.exe] [options] --NoExit - Does not exit after running startup commands. +PowerShell[.exe] -h | -Help | -? | /? --NoProfile - Does not load the PowerShell profile. +PowerShell Online Help https://docs.microsoft.com/en-us/powershell/scripting/powershell-scripting?view=powershell-6 --NonInteractive - Does not present an interactive prompt to the user. +All parameters is case-insensitive. --Interactive - Present an interactive prompt to the user. +-Command | -c + 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. --InputFormat - Describes the format of data sent to PowerShell. Valid values are - "Text" (text strings) or "XML" (serialized CLIXML format). + If the value of Command is "-", the command text is read from standard input. --OutputFormat - Determines how output from PowerShell is formatted. Valid values - are "Text" (text strings) or "XML" (serialized CLIXML format). + If the value of Command is a script block, the script block must be enclosed + in braces ({}). You can specify a script block only when running 'powershell' + in PowerShell. The results of the script block are returned to the + parent shell as deserialized XML objects, not live objects. --WindowStyle - Sets the window style to Normal, Minimized, Maximized or Hidden. + 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. --EncodedCommand - Accepts a base-64-encoded string version of a command. Use this parameter - to submit commands to PowerShell that require complex quotation - marks or curly braces. + 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 executed. + + Example: + powershell -Command {Get-WinEvent -LogName security} + powershell -command "& {Get-WinEvent -LogName security}" --ConfigurationName +-ConfigurationName | -config 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. - --File - Runs the specified script in the local scope ("dot-sourced"), so that the - functions and variables that the script creates are available in the - current session. Enter the script file path and any parameters. - File must be the last parameter in the command, because all characters - typed after the File parameter name are interpreted - as the script file path followed by the script parameters. + 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. + + Example: powershell -configurationmame AdminRoles --ExecutionPolicy +-EncodedCommand | -e | -ec + Accepts a base-64-encoded string version of a command. Use this parameter to submit + commands to PowerShell that require complex quotation marks or curly braces. + + Example: + $command = 'dir "c:\program files" ' + $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) + $encodedCommand = [Convert]::ToBase64String($bytes) + powershell -encodedcommand $encodedCommand + +-ExecutionPolicy | -ex | -ep Sets the default execution policy for the current session and saves it in the $env:PSExecutionPolicyPreference environment variable. This parameter does not change the PowerShell execution policy that is set in the registry. --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. + Example: powershell -ExecutionPolicy RemoteSigned - If the value of Command is "-", the command text is read from standard - input. +-File | -f + Default parameter if no parameters is present but any values is present in the command line. + Runs the specified script in the local scope ("dot-sourced"), so that the functions + and variables that the script creates are available in the current session. + Enter the script file path and any parameters. File must be the last parameter + in the command, because all characters typed after the File parameter name are interpreted + as the script file path followed by the script parameters. - If the value of Command is a script block, the script block must be enclosed - in braces ({}). You can specify a script block only when running PowerShell.exe - in PowerShell. The results of the script block are returned to the - parent shell as deserialized XML objects, not live objects. + Example: powershell HelloWorld.ps1 - 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. +-Help | -h | -? | /? + Shows this message. If you are typing a 'powershell' command in PowerShell on Windows + system, prepend the command parameters with a hyphen (-), not a forward slash (/). + You can use either a hyphen or forward slash in Cmd.exe. - 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 executed. +-InputFormat | -in | -if + Describes the format of data sent to PowerShell. + Valid values are "Text" (text strings) or "XML" (serialized CLIXML format). --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 -Version - PowerShell -ConfigurationName AdminRoles - PowerShell -Command {Get-EventLog -LogName security} - PowerShell -Command "& {Get-EventLog -LogName security}" - PowerShell HelloWorld.ps1 - - # To use the -EncodedCommand parameter: - $command = 'dir "c:\program files" ' - $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) - $encodedCommand = [Convert]::ToBase64String($bytes) - powershell -encodedCommand $encodedCommand +-Interactive | -i + Present an interactive prompt to the user. Inverse for NonInteractive parameter. + +-NoExit | -noe + Does not exit after running startup commands. + + Example: powershell.exe -NoExit -Command Get-Date + +-NoLogo | -nol + Hides the copyright banner at startup. + +-NonInteractive | -noni + Does not present an interactive prompt to the user. Inverse for Interactive parameter. + +-NoProfile | -nop + Does not load the PowerShell profiles. + +-OutputFormat | -o | -of + Determines how output from PowerShell is formatted. Valid values + are "Text" (text strings) or "XML" (serialized CLIXML format). + Default is "Text". + + Example: powershell -o XML -c Get-Date + +-Version | -v + Shows the version of PowerShell and exits. Additional arguments are ignored. + + Example: powershell -v + +-WindowStyle | -w + Sets the window style to Normal, Minimized, Maximized or Hidden. + From 55e447e66d5a0826a6ad75b59738abc32c9b677d Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 4 Oct 2017 07:24:07 +0300 Subject: [PATCH 2/4] Correct typo and add short link --- .../resources/ManagedEntranceStrings.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx index 24a589ce209..0753cc2b2d6 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx +++ b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx @@ -126,9 +126,9 @@ Copyright (C) Microsoft Corporation. All rights reserved. PowerShell[.exe] -h | -Help | -? | /? -PowerShell Online Help https://docs.microsoft.com/en-us/powershell/scripting/powershell-scripting?view=powershell-6 +PowerShell Online Help https://aka.ms/pscore6-docs -All parameters is case-insensitive. +All parameters are case-insensitive. -Command | -c Executes the specified commands (and any parameters) as though they were typed From 095c6eca9dd1bba75345675f47c7d4888a454c41 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Wed, 4 Oct 2017 08:48:13 +0300 Subject: [PATCH 3/4] Add "Usage:" --- .../resources/ManagedEntranceStrings.resx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx index 0753cc2b2d6..d4fae30fc5c 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx +++ b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx @@ -122,9 +122,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. - PowerShell[.exe] [options] - -PowerShell[.exe] -h | -Help | -? | /? + Usage: powershell[.exe] [[-File] <filePath> [args]] + [-Command { - | <script-block> [-args <arg-array>] + | <string> [<CommandParameters>] } ] + [-ConfigurationName <string>] [-EncodedCommand <Base64EncodedCommand>] + [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}] + [-Interactive] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile] + [-OutputFormat {Text | XML}] [-Version] [-WindowStyle <style>] + + powershell[.exe] -h | -Help | -? | /? PowerShell Online Help https://aka.ms/pscore6-docs From 39467dd004cb3cf8944c9c47770a5a448124ccdc Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 5 Oct 2017 08:34:18 +0300 Subject: [PATCH 4/4] Use "base64 encoded" --- .../resources/ManagedEntranceStrings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx index d4fae30fc5c..81021421024 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx +++ b/src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx @@ -168,7 +168,7 @@ All parameters are case-insensitive. Example: powershell -configurationmame AdminRoles -EncodedCommand | -e | -ec - Accepts a base-64-encoded string version of a command. Use this parameter to submit + Accepts a base64 encoded string version of a command. Use this parameter to submit commands to PowerShell that require complex quotation marks or curly braces. Example: