Search code examples
powershellcronscheduled-taskstaskschedulerstart-job

PowerShell-Script in PowerShell-Script with Task Scheduling


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


Solution

  • 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!