If neither -Path nor -LiteralPath is specified, Export-Csv emits an error message telling the user they must not specify both -Path and -LiteralPath.
$null | Export-Csv -NoTypeInformation -Encoding utf8
Export-Csv: You must specify one of : -Path / -LiteralPath
or: the cmdlet should prompt for the value for the Path parameter.
Export-Csv: You must specify either the -Path or -LiteralPath parameters, but not both.
> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.0-rc.2
PSEdition Core
GitCommitId 7.0.0-rc.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
We just use the same message for several errors. I don鈥檛 think it is worth the effort.
/cc @SteveL-MSFT @joeyaiello for conclusion.
As an aside: The problem wouldn't arise if -Path and -LiteralPath were in different parameter sets and mandatory in each - as they should be.
Yeah, this pattern seems to be a pretty old one. Not sure why we're still using it in any of these cmdlets.
Most helpful comment
As an aside: The problem wouldn't arise if
-Pathand-LiteralPathwere in different parameter sets and mandatory in each - as they should be.