Prerequisites
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
Prerequisites
Steps to reproduce
This is a sub-issue of #25242.
The cmdlets
Export-CsvandConvertTo-Csvdo not respect explicit$falsevalues for the-IncludeTypeInformationand-NoTypeInformationswitch parameters in conflict validation.Expected behavior
-IncludeTypeInformation:$false -NoTypeInformation:$falseshould behave the same as omitting both switches, using the default behavior without throwing an error.Actual behavior
-IncludeTypeInformation:$false -NoTypeInformation:$falsebehaves the same as-IncludeTypeInformation:$true -NoTypeInformation:$true, throwing an error as if both switches were set to$true.Error details
Environment data
Visuals
No response