0

I need help understanding why the scheduled task is not working, even though the last successful Run Time says,

The operation completed successfully.

The result is that it's not copied to the destination folder, but if I run the .ps1 script manually, it completes successfully.


1

enter image description here

2

enter image description here

FIG 3

enter image description here**

Add-ExecutionPolicy Bypass C:\auto_p\applied.ps1

4

enter image description here

5

enter image description here

6

enter image description here

TylerH
  • 20,799
  • 66
  • 75
  • 101
kimjong
  • 11
  • 2
  • Can you add `Start-Transcript` and `Stop-Trascript` to your code to see what's happening at execution? Possibly increasing verbosity. – another victim of the mouse Jun 17 '22 at 21:39
  • So I have run into so many issues in the past regarding scheduled tasks via cmd or powershell. This post is a really good summary of some of those issues (in case there is relation which in this case I am not totally sure there is).... However, I am interested in the script you are executing via scheduled task. Which method are you using to write to the destination? Also, is your the user your task is being run 'as' configured correctly in regards to administrative permissions? – SilentZ Jun 17 '22 at 23:13
  • 2
    Looks like you running the task under the SYSTEM account. if that is indeed the case, you might have a look here: [Scheduled Task Powershell Script - Runs OK as user account, but not as SYSTEM](https://stackoverflow.com/a/51612478/1701026) – iRon Jun 18 '22 at 10:07
  • @SilentZ Hey there, thanks for your input, this my script `Get-ChildItem -Path "F:\*" -filter *AppliedInnovations*.txt | Copy-Item -Destination "O:\Applied Innovations Database\" -PassThru` – kimjong Jun 20 '22 at 13:21

1 Answers1

0

For me, I just write as below
Program/Script:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Argumente :
"Powershell -ExecutionPolicy Bypass -File "E:\Skript\example.ps1"

A small tip:
You also need to make sure your script does not include some folder shortcut from network.
If there is a source / destination folder from network, please write the complete part of the network instead of your shortcut drive alphabet.

dodrg
  • 1,142
  • 2
  • 18