简体   繁体   中英

Task Scheduler Task Completes Script Does not Run

I have a simple powershell job that copies a file from my computer to a network folder. I have verified that it is able to run when manually triggered, but not through task scheduler. When triggering the task from Scheduler the history indicated that it has run as I get both "Action Completed" and "Task Completed".

copy C:\test.txt "\\network\folder\destination\" /Z /Y

On the job itself:

Action:

-Program/Script: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe

-Arguments: -file "C:\\Users\\me\\Desktop\\move.ps1"

Its allowed to run on demand, running through a user with access to the network folder, with highest privileges. Any trouble shooting ideas are greatly appreciated.

You're trying to call a cmd function from PowerShell which has copy aliased to the Copy-Item cmdlet by default. You'd need to modify your script to call cmd if you want to keep that line as it is.

& cmd /c copy C:\test.txt \\network\folder\destination /Z /Y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM