Skip to content

CLI: Ambiguous parameter names such as -no are misinterpreted as positional parameter values #4351

@mklement0

Description

@mklement0

Steps to reproduce

# -no is ambiguous: could be -NoProfile, -NoLogo, ...
powershell -no -command get-date

Expected behavior

An error complaining about the ambiguity of the parameter name and refusal to continue.

Actual behavior

PS Core and Windows PS behave differently, due to the recent Core change to default to -File instead of -Command:

  • PowerShell Core:
The argument '-no' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
PowerShell v6.0.0-beta.4
Copyright (C) Microsoft Corporation. All rights reserved.
  • Windows PowerShell:
-no : The term '-no' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ -no -command get-date
+ ~~~
    + CategoryInfo          : ObjectNotFound: (-no:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Environment data

PowerShell Core v6.0.0-beta.4 on macOS 10.12.5
PowerShell Core v6.0.0-beta.4 on Ubuntu 16.04.2 LTS
PowerShell Core v6.0.0-beta.4 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.413 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions