Skip to content

ErrorAction for Test-Path throw an NullReferenceException #11692

@LaurentDardenne

Description

@LaurentDardenne

Steps to reproduce

#new PS session
# The variable 'Stop' not exist

Test-Path .\File.ps1 -ErrorAction $Stop

Expected behavior

message = Invalid value ?

Actual behavior

Test-Path: Cannot bind parameter 'ErrorAction' to the target.
Exception setting "ErrorAction": "Object reference not set to an instance of an object."

Environment data

```Powershell
Name                           Value
----                           -----
PSVersion                      7.0.0-rc.2
PSEdition                      Core
GitCommitId                    7.0.0-rc.2
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0-rc.2}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Same issue with Windows PowerShell 5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions