Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

-IncludeTypeInformation:$false -NoTypeInformation:$false not respected in Export-Csv/ConvertTo-Csv #26569

Copy link
Copy link
@yotsuda

Description

@yotsuda
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.