Problem Getting a Powershell Script to Run in Task Scheduler Solved

  1.    #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!


    Al Guden

      My ComputerSystem Spec

  2.    #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
      My ComputersSystem Spec

  3.    #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.

      My ComputerSystem Spec

  4.    #4

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


Related Threads
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...
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...
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...
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 20:33.
Find Us