Skip to content

Invoke-WebRequest -PassThru, when combined with -OutFile, should reflect the download file path. #21082

@mklement0

Description

@mklement0

Summary of the new feature / enhancement

Thanks to a contribution by @CarloToso, since v7.4.0 it has been possible to pass a directory rather than a file path to -OutFile, in which the web cmdlets use the (ultimate) target URL's last segment as the file name.

Given that, when redirections are involved, you won't know what that last segment is, being able to programmatically discover the resulting full download file path is important.

This will also apply to the planned support for using a server-suggested output file name via a Content-Disposition response header field - see PR #19385

(Using -Verbose is a way to discover the file name interactively; while it's technically possible to programmatically parse the verbose output, that would be both cumbersome and brittle).

Thus - at least when -OutFile is used - the [Microsoft.PowerShell.Commands.WebResponseObject] instance returned via -PassThru should have an .OutFile property or similar that reflects the output file's full path.

Related:

Proposed technical implementation details (optional)

I don't know whether it's worth extending [Microsoft.PowerShell.Commands.WebResponseObject] or not.

If not, an ETS NoteProperty member could be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions