Prerequisites
Steps to reproduce
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, using -Verbose is an important way to discover the effective output file name.
Unfortunately, -Verbose currently misreports the directory's name as the output file name:
# This downloads to file /tmp/ascii_to_unicode.bat
Invoke-WebRequest -Verbose -OutFile /tmp https://filesamples.com/samples/code/bat/ascii_to_unicode.bat
# Clean up
Remove-Item /tmp/ascii_to_unicode.bat
Expected behavior
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 response of content type application/octet-stream of unknown size
VERBOSE: File Name: ascii_to_unicode.bat
Actual behavior
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 response of content type application/octet-stream of unknown size
VERBOSE: File Name: tmp
That is, the directory's name is reported.
Error details
No response
Environment data
Visuals
No response