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

Invoke-RestMethod parameter combination of OutFile/PassThru does not write to file as intended #15409

Copy link
Copy link
@sdwheeler

Description

@sdwheeler
Issue body actions

Problem description

In Invoke-RestMethod, the PassThru parameter must be used with the OutFile parameter. The intent is that you can write the results to the file and get the output to the pipeline. But the cmdlets only write to the pipeline, not the file.

The problem code starts here:

if (ShouldWriteToPipeline)
{
   ...
}
else if (ShouldSaveToOutFile)
{
   ...
}

Notice that the logic outputs pipeline and skips the output to the file. Both ShouldWriteToPipeline and ShouldSaveToOutFile can be true so need to remove the else.

Steps to reproduce

Invoke-RestMethod https://taxonomyservice.azurefd.net/taxonomies/product-uri -PassThru -OutFile C:\temp\irm.json

Expected behavior

Output to console and to the file.

Actual behavior

Output to console only. The output file is not created.

Environment data

This affects all versions 5.1 and higher.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a 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.