-1

I need to load a https file. I use wget with option --no-check-certificate. It runs perfectly if started by the ISE-debugger. It even runs perfectly if I started in the cmd-console: ./myScript.ps1. But as soon as I set the Task Scheduler to start my script I get:

--2016-02-07 19:44:01--  https://www.dailyfx.com/calendar/
Resolving www.dailyfx.com... 104.87.22.147
Connecting to www.dailyfx.com|104.87.22.147|:443... connected.
WARNING: cannot verify www.dailyfx.com's certificate, issued by `/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3':
  Unable to locally verify the issuer's authority.
WARNING: certificate common name `fxcm.com' doesn't match requested host name `www.dailyfx.com'.
HTTP request sent, awaiting response... 403 Forbidden
2016-02-07 19:44:01 ERROR 403: Forbidden.

Before calling I set the $ArgList and then I call wget:

$urlDFx  = "https://www.dailyfx.com/calendar/"
$argList = "$urlDFx -O $rawDFx -o $logDFx --no-check-certificate"
$wg = Start-Process wget -wait -NoNewWindow -PassThru -ArgumentList $argList

The other variables are various local files.

Again, it works in the ISE and the CMD console but not if started by the Task Scheduler. The other part of the scripts are executed without any problem: I did another http-file and parse it.

What can I do?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
gooly
  • 1,241
  • 7
  • 20
  • 38
  • Are you using a service account to run the script under task scheduler? Or the same (user) account that you're running ISE/cmd-console and testing the script under? Also, I'm curious why you wouldn't use Invoke-WebRequest for this? – Robin Feb 07 '16 at 19:10
  • I am using 'me' as user to do everything. wget is quite fast ans easy to use! – gooly Feb 07 '16 at 20:23

1 Answers1

0

I have found a solution even if I don't understand why this now works! I set:

    $argList = "$urlDFx -O $rawDFx -o $logDFx --no-check-certificate --verbose "

1) It works even if the task-scheduler has started the script. 2) The log-file of wget contains absolutely the same as before. (May be now --verbose is skipped??)

gooly
  • 1,241
  • 7
  • 20
  • 38