-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-AnsweredThe question is answered.The question is answered.
Description
The powershell command line docs suggest that the "-Command" option may be used with the "-args" option to pass extra arguments to a script block. However, this does not work as described.
Recommend updating the command line documentation to document the actual behavior of -Command, which does not support an -args option.
Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
Steps to reproduce
powershell.exe -Command "{ echo $args[1] }" -args one two threeExpected behavior
print two
Actual behavior
error:
aaronla@aaronla-r:scratch$ dotnet pwsh -command "{ echo $args[1] }" -args one two three
ParserError:
Line |
1 | { echo $args[1] } -args one two three
| ~~~~~
| Unexpected token '-args' in expression or statement.
Environment data
aaronla@aaronla-r:PowerApps-CoreServices$ dotnet pwsh -command echo $PSVersionTable
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Metadata
Metadata
Assignees
Labels
Resolution-AnsweredThe question is answered.The question is answered.