Question

I was wondering if it is possible to download a file from a URL that has been redirected with a powershell script. (I'm running Windows 8)

At work we use Combofix and other miscellaneous programs to clean the employees computers for malicious software.

Combofix gets an update quite often and we use the program several times a week, I thought it'd been nice to always have the latest version of Combofix on my computer.

The download URL looks like this:

http://www.bleepingcomputer.com/download/combofix/dl/12/

When you open the URL, you will be redirected to a URL that looks like this:

http://download.bleepingcomputer.com/dl/50b8cfbdcd418904cebb8e420ca12d36/52e915a4/windows/security/anti-virus/c/combofix/ComboFix.exe

I can't use this URL more than once, since it will expire within 10 minutes.

Was it helpful?

Solution

you could do it that way :

$rep=Invoke-WebRequest http://www.bleepingcomputer.com/download/combofix/dl/12/ -MaximumRedirection 0 
$rep.Links | where {$_.innerText -eq "click here"} |select -expand href 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top