1. Joined : Dec 2015
    Wellington, FL
    Posts : 8
    Windows 10
       4 Weeks Ago #1

    Problem Getting a Powershell Script to Run in Task Scheduler


    Hope I'm in the right place!

    I am trying to get a Powershell script to run daily in the task scheduler. It basically purges a folder on one of my drives:

    Get-ChildItem –Path “D:\Dropbox\Quicken\Backup” –Recurse | Where-Object CreationTime –lt (Get-Date).AddDays(-10) | Remove-ItI

    I can run it from a CMD prompt and I set it up in the task scheduler and it seemed to run one time on schedule and then hasn't run since that initial time. I have tried to run it manually from the task scheduler but it gets and error "Task Start Failed."

    I have attached copies of the properties tabs and the main view of the task scheduler with the History showing. Any ideas? I didn't find a tutorial, but I'm sure there is something on the website!

    Cordially,

    Al Guden

    TS-TaskView.pdf
    PROPERTIES-Settings.pdf
    PROPERTIES-Actions.pdf
    PROPERTIES-Triggers.pdf
    PROPERTIES-General.pdf
    PROPERTIES-History.pdf
    PROPERTIES-Conditions.pdf
      My System SpecsSystem Spec


  2. Joined : Jan 2015
    UK, Midlands
    Posts : 6,233
    Win 10 Pro (1607)
       4 Weeks Ago #2

    Hi, I think you need to create a powershell script file and specify that as your action, not the specific powershell command.

    See this for an extended example, and another below:
    Weekend Scripter: Use the Windows Task Scheduler to Run a Windows PowerShell Script Hey, Scripting Guy! Blog

    https://community.spiceworks.com/how...task-scheduler
      My System SpecsSystem Spec


  3. Joined : Dec 2015
    Wellington, FL
    Posts : 8
    Windows 10
       4 Weeks Ago #3

    Thank you for the help. The 2nd article had the little nugget I needed. -ExecutionPolicy Bypass before the PS1 file did the trick. I started using a PS1 file but couldn't get past the errors with scripts being prohibited. This did the trick. It runs manually. Now we will see if it runs on schedule.

    Thanks again.

    Al
      My System SpecsSystem Spec


  4. Joined : Jan 2015
    UK, Midlands
    Posts : 6,233
    Win 10 Pro (1607)
       4 Weeks Ago #4

    Glad it helped- the answer's often 'out there'...
      My System SpecsSystem Spec


 


Similar Threads
Thread Forum
Solved Task Scheduler and Bat File Problem
Hi, Not sure which forum to post this in, but hopefully someone has some insight and can help me with this. I have a simple .bat file that stops my media server, creates an archive of a folder (for backup purposes), and then starts the media...
General Support
How to show Command Prompt Window when running task in Task Scheduler?
Is there a way to make the "Command Prompt" window show when I have a task running in Windows task Scheduler? I would like to be able to view the progress of the task. For example, I have a program called "Zap2xml" that collects TV EPG data. It...
General Support
What script do I use in Task Scheduler to delay/minimize on startup?
I am creating a task in the task scheduler to delay the startup of OneDrive for 5 minutes and it is working but when it launches it is opening a window instead of minimizing or running in background. I am using "\minimize" as argument but it's not...
General Support
Task Scheduler problem - Past Windows 7 tasks give error popups
After an in-place upgrade from Windows 7 to Windows 10, Task Scheduler always comes with error popups for many tasks. "Task X: The task object version is either unsupported or invalid." After closing all of them, I can get into Task Scheduler but I...
Performance & Maintenance
Solved Time Zone change causes error in Task Scheduler for every task
My issue is kind of strange. I am an insider currently on Windows 10 build 10240. All the build I have tried so far has this same error in task scheduler when I change my time zone to my current location which is kathmandu (UTC+5:45). When i change...
Performance & Maintenance
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 22:01.
Find Us
Twitter Facebook Google+



Windows 10 Forums