0

wget -N (or more verbose wget --timestamping) has the nice effect that files that are already downloaded are not attempted to be downloaded again.
That way you can save time and resources. I'm looking for the equivalent in PowerShell's Invoke-WebRequest.

Is there a way to respect the file's and the server's time stamp in Invoke-WebRequest?

guerda
  • 23,388
  • 27
  • 97
  • 146

1 Answers1

0

based on what i can find in the documentation, no, it doesn't appear that Invoke-WebRequest has an option similar to that.

the best i could tell you is to check yourself in a script through conditionals and saving the new file with a different file name, since if you're using Invoke-WebRequest to download a file, i can only assume you're also using -OutFile as an option;

$File1Creation=(Get-ChildItem <PathToFile1> -Force).CreationTime
Invoke-WebRequest -Uri https://website.com -Outfile <PathToFile2>
$File2Creation=(Get-ChildItem <PathToFile2> -Force).CreationTime
if ($File1Creation -eq $File2Creation)
{
    #do something here
} else {
    #do something else here
}

the biggest problem is that, because I-WR doesn't have an option similar to it, unless your file has a timestamp embedded somewhere on its originating webpage, there's no way to check it prior to actually downloading it.

EarthToAccess
  • 71
  • 1
  • 10