0

at the moment I try to automize an RDWeb on my Windows-Server. Therefore, I wrote a PowerShell-Script for the database-readout and a second script, which is started everytime the database returns a value.

This second script is started with Start-Job -Scriptblock {./second.ps1 -values args[0]} -Arguments $values;

This works perfect, if I run this script manually as Admin in the ISE, but if I try this in Windows Task Schedule, it doesn't work and I don't know why. I run the Scheduletask with the highest priviledges.

Can you help me please?

Thank you SUT

SUT
  • 323
  • 1
  • 3
  • 14
  • The ISE will retain script variables. When Task scheduler starts Powershell, any variables the task depends on will not be present. What happens when you close the ISE and run the `Start-Job` command? – user4317867 Jan 28 '17 at 15:11
  • Do you wait for job to complete in your script? – user4003407 Jan 28 '17 at 20:30
  • No - I complete the script without waiting for the jobs I run the jobs in background - so the readout-script just finish and the others (different second.ps1-scripts) continue – SUT Jan 29 '17 at 20:33

2 Answers2

0

What speaks against to use the full path instead of "./second.ps1" ?

Buxmaniak
  • 460
  • 2
  • 4
0

I solved the problem. The problem was that I didn't wait for the scripts, which are running in background, before I closed the Main-Script.

So the Task Scheduler stopped every process, which was running in background, when the main-script finished the process

Thank your for your answers!

SUT
  • 323
  • 1
  • 3
  • 14