Windows 10: Problem Getting a Powershell Script to Run in Task Scheduler Solved

  1.    06 Nov 2016 #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.    06 Nov 2016 #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.    06 Nov 2016 #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.    06 Nov 2016 #4

    Glad it helped- the answer's often 'out there'...
      My System SpecsSystem 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...
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...
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...
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...
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 13:11.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums