Powershell & Vb Script: upload & download file from a url with credentials

Luis Diaz
Luis Diaz used Ask the Experts™
on
Hello experts,
I am looking for a script to :
-Upload file to an url
-Download specific and last modified file from a url
To access to this url I need to report credentials. User and password.
I heard about cUrl application however if this is possible through a build-in language such as powershell or vbscript I a prefer this approach.
As regards the upload and the download the script should manage success and error actions in a log file.
Thank you in advance for your feedback.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
You do not have any way to check for "last modified file from a url" because you do not have any query interface by default.

Whether you can use credentials depends on the target site. If  it requires login thru a form, this can be done often (but not in all cases) by parsing the HTML response. Sometimes you can POST credentials.
Luis DiazIT consultant

Author

Commented:
Ok, thank you for your feedback.
Here is the command that I have to do it through cURL:
Export:
@echo off

rem Set curl path.
set CURL="curl/curl"

cd "C:\Test"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set action url.
set ACTION_URL=%SITE_URL%/getLastFile/62

rem Set input file path and name.
set PARAM_PROXY=

set FILE="toto.txt"

rem Import the file.
curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -o %FILE%

pause

Open in new window


Send:
@echo off

rem Set curl path.
set CURL="curl/curl"

cd "C:\Temp"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set action url.
set ACTION_URL=%SITE_URL%/sendFile/51

rem Set input file path and name.
set PARAM_PROXY=

set FILE="file=@filename.csv"

rem Import the file.
curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -F %FILE%

pause

Open in new window


How we can translate them to vbscript or powershell?
Thank you very much for your help.
Luis DiazIT consultant

Author

Commented:
I will use cURL as it works for me.
Thank you anyway for your help.
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
If it is that simple with curl, I see no reason to change anything ;-).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial