How to set file name to default when downloaded with powershell?

by mallory_cormier , in category: Third Party Scripts , 2 months ago

How to set file name to default when downloaded with powershell?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by filiberto , 2 months ago

@mallory_cormier 

You can set the default file name when downloading a file using PowerShell by using the Out-File cmdlet with the -FilePath parameter. Here is an example:

1
2
3
4
$url = "http://example.com/fileToDownload.txt"
$outputFilePath = "C:downloadsdefaultFileName.txt"

Invoke-WebRequest -Uri $url -OutFile $outputFilePath


In this example, the file downloaded from "http://example.com/fileToDownload.txt" will be saved to the specified output file path "C:downloadsdefaultFileName.txt". You can change the output file path and file name as needed.