Skip to content

Import-Csv has distinct -Path and -LiteralPath parameters, yet the -Path parameter doesn't support wildcards properly #4472

@mklement0

Description

@mklement0

[Superseded by the generalized #6583]

Related: #4473.

The purpose of having distinct -Path and -LiteralPath parameters is to allow the former to accept paths based on wildcard expressions, whereas the latter must be used for paths to be used as-is.

Import-Csv has both parameters, and while the -Path parameter clearly resolves a wildcard expression, it fails if the expression resolves to more than 1 file.

Note that -Path is declared as [string[]], so it is capable of accepting multiple files, if passed as an array of paths.

Steps to reproduce

'file1.csv', 'file2.csv' | % { $null > $_ }
Import-Csv -Path file*.csv

Expected behavior

No output (null collection), given that both files are empty.

Actual behavior

The following statement-terminating error is reported:

Import-Csv : Cannot perform operation because the path resolved to more than one file. This command cannot operate on multiple files.

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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions