-IncludeTypeInformation:$false -NoTypeInformation:$false not respected in Export-Csv/ConvertTo-Csv
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
This is a sub-issue of #25242.
The cmdlets Export-Csv and ConvertTo-Csv do not respect explicit $false values for the -IncludeTypeInformation and -NoTypeInformation switch parameters in conflict validation.
PS> 'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false -NoTypeInformation:$false PS> 'test' | ConvertTo-Csv -IncludeTypeInformation:$false -NoTypeInformation:$false
Expected behavior
PS> 'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false -NoTypeInformation:$false PS> # No error - both switches are $false, so there is no conflict
-IncludeTypeInformation:$false -NoTypeInformation:$false should behave the same as omitting both switches, using the default behavior without throwing an error.
Actual behavior
PS> 'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false -NoTypeInformation:$false Export-Csv: Cannot specify both -IncludeTypeInformation and -NoTypeInformation.
-IncludeTypeInformation:$false -NoTypeInformation:$false behaves the same as -IncludeTypeInformation:$true -NoTypeInformation:$true, throwing an error as if both switches were set to $true.
Error details
PS> Get-Error Exception : Type : System.InvalidOperationException Message : Cannot specify both -IncludeTypeInformation and -NoTypeInformation. HResult : -2146233079 FullyQualifiedErrorId : CannotSpecifyIncludeTypeInformationAndNoTypeInformation
Environment data
PS> $PSVersionTable Name Value ---- ----- PSVersion 7.5.0 PSEdition Core GitCommitId 7.5.0 OS Microsoft Windows 10.0.22631 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