AnsweredAssumed Answered

Web file download using Powershell

Question asked by bcmillerway on Dec 19, 2018
Latest reply on Dec 20, 2018 by Reid Larson

Hi folks,

I'm trying to find the best way to download a binary file from a website using only methods native to Windows.  There are various approaches, I'm looking at Powershell right now.  -Yes, I've researched this -without results.


I have the commands that will work in Powershell, the download occurs immediately if the commands are pasted into a Powershell window.  But when using them in a Send Event script step -it doesn't happen.  This is being run locally, not on FMPserver.  I happen to be using Windows 7, FMP v14.


Here's my Send Event setup -all the commands at once:


cmd /c Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force &&

cmd /c $webclient = New-Object System.Net.WebClient &&

cmd /c $storageDir = "C:\Users\Someone\Desktop" &&

cmd /c $url = "" &&

cmd /c $file = "$storageDir\Filename.exe" &&

cmd /c $webclient.DownloadFile($url,$file) &&

cmd /c Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Restricted -Force


(In a Powershell window the first and last step aren't needed.)


I've also tried putting each command in a separate Send Event step -no luck.


If someone else has worked this out, I'd appreciate some guidance.