Skip to content

Make Export-FormatData syntax support specifying the output file positionally #6680

Description

Related: #6681

Currently, you cannot positionally specify an output file for Export-FormatData, even though it is typically the only (non-switch) parameter, and other export-/file-writing cmdlets you do allow you to specify the target file positionally.

I'd expect all of the following forms to be equivalent:

... | Export-FormatData foo.format.ps1xml  # !! NOT supported: positional out-file argument
... | Export-FormatData -Path foo.format.ps1xml
... | Export-FormatData -LiteralPath foo.format.ps1xml

Also, given that -Path doesn't support wildcards, there's no need for a separate parameter set, and so -Path can simply be made an alias of -LiteralPath. (-Path, perhaps surprisingly, does support wildcard expressions, as long as they resolve to a single file.)

Environment data

Written as of:

PowerShell Core v6.0.2

Activity

  1. BrucePay commented on Apr 24, 2018

    @BrucePay
    Collaborator

    Michael Klement (@mklement0)

    Also, given that -Path doesn't support wildcards,

    Umm - it most definitely supports wildcards, as in:

    Get-FormatData | Export-FormatData -Path b*r.*
    
  2. mklement0 commented on Apr 24, 2018

    @mklement0
    ContributorAuthor

    Bruce Payette (@BrucePay):

    Ah, indeed. I got confused, because in my test command the wildcard resolved to multiple matches.

    And that brings us to the larger point:

    Output-file creating cmdlets shouldn't support wildcards for their output file-path parameter.

    I'll open a separate issue for that.

  3. mklement0 commented on Apr 24, 2018

    @mklement0
    ContributorAuthor

    Bruce Payette (@BrucePay):

    Spoke too soon: the part about how Export-FormatData should support a positional output file-path argument still applies in this specific case, so I'm reopening this with the wildcard-related part crossed out.

  4. mklement0 commented on Apr 24, 2018

    @mklement0
    ContributorAuthor

    Re not permitting wildcard expressions with -Path - please see #6714

  5. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or more

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions