Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Downloading from temporary link with Powershell


  • Please log in to reply
1 reply to this topic

#1 mysticduck

mysticduck

  • Members
  • 35 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Southern Oregon
  • Local time:03:03 PM

Posted 06 April 2015 - 02:12 PM

Howdy.  I have a Powershell script I use to download some files daily.

$client = new-object system.Net.Webclient
$client.Downloadfile("http://www.adlice.com//?smd_process_download=1&download_id=2180","\\syn\software\tools\roguekill.exe")
$client.downloadfile("http://www.adlice.com//?smd_process_download=1&download_id=2181","\\syn\software\tools\roguekill64.exe")
$client.downloadfile("http://dl.surfright.nl/HitmanPro.exe","\\syn\software\tools\hitmanpro.exe")
$client.downloadfile("http://dl.surfright.nl/HitmanPro_x64.exe","\\syn\software\tools\hitmanpro_x64.exe")
$source = "http://media.kaspersky.com/utilities/VirusUtilities/EN/tdsskiller.exe"
$dest = "\\syn\software\tools\tdsskiller.exe"
Invoke-WebRequest $source -OutFile $dest
exit 

I had to use the two different methods at some point to fix some download problem.  Anywho, I want to be able to download adwcleaner daily but I can't find a static link for it.  The link from here at Bleeping changes frequently and the one at toolslib doesn't work in the script, it doesn't point to an exe.  Any ideas out there?    


Stultorum infinitus est numerus

BC AdBot (Login to Remove)

 


m

#2 JohnnyJammer

JohnnyJammer

  • Members
  • 1,107 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:08:03 AM

Posted 08 April 2015 - 07:05 PM

Im pretty sure that system.net.WebClient doesnt support a HEAD request to see if the file exists before performing the Downloadfile command.

the next thing i would do is use the HttpWebRequest instead to see fi it exists first and if true then use the $client.Downloadfile.

remember with powershell you can utilise the .net framework mate.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users