Skip to content

test-path $null throws error #24468

@rkitover

Description

@rkitover

Prerequisites

Steps to reproduce

test-path $null

Expected behavior

$false

Actual behavior

Test-Path: Value cannot be null. (Parameter 'The provided Path argument was null or an empty collection.')

Error details

Exception             :
    Type      : System.ArgumentNullException
    Message   : Value cannot be null. (Parameter 'The provided Path argument was null or an empty collection.')
    ParamName : The provided Path argument was null or an empty collection.
    HResult   : -2147467261
CategoryInfo          : InvalidArgument: (:) [Test-Path], ArgumentNullException
FullyQualifiedErrorId : NullPathNotPermitted,Microsoft.PowerShell.Commands.TestPathCommand
InvocationInfo        :
    MyCommand        : Test-Path
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : test-path $null
    Statement        : test-path $null
    PositionMessage  : At line:1 char:1
                       + test-path $null
                       + ~~~~~~~~~~~~~~~
    InvocationName   : test-path
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
      0
      1

Environment data

PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.27729
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions