Run powershell script using Task Scheduler

Peizhi_Yu 6 Reputation points
2020-09-14T00:22:07.777+00:00

I have a script that is reset password of the user.

I want to run it use task scheduler every hour once.

But is failed.

The history of scheduler show the task completed.
but the script don't have any out.

This is my action set
24186-1.png

Windows for business Windows Server User experience PowerShell
{count} vote

4 answers

Sort by: Most helpful
  1. Cesar Contreras 26 Reputation points
    2021-09-04T13:47:20.03+00:00

    Several points to troubleshoot:

    1. To confirm if PowerShell command is able to execute and check the results, open a D.O.S. session (cmd.exe) and execute the command and parameters registered on the Scheduled task.

    i.e

    powershell.exe -file "c:\temp\hello.ps1"
    
    C:\Temp>powershell.exe -file "c:\temp\hello.ps1"
    

    Once is confirmed executing correctly try again with the schedule.


    1. In order to have more feedback you can use Start-Transcript / Stop-Transcript commands to log any execution details on a Log file.
      1. Confirm the resources used by your script, for instance if you are using network resources you will need your schedule task to be logged as an user to work.
    5 people found this answer helpful.

  2. Anthony 6 Reputation points
    2021-09-16T19:47:40+00:00

    I don't know if you ever figured it out but from the look of your screenshot you have a forward slash in your arguments for the file path. Windows file paths use backslashes.

    1 person found this answer helpful.
    0 comments No comments

  3. Anonymous
    2020-09-14T02:37:33.46+00:00

    Hi,
    Task completed does not mean the script has been executed successfully. Can you run the script manually?
    Best Regards,
    Ian


  4. MotoX80 36,291 Reputation points
    2020-09-14T14:15:51.587+00:00

    Add the Start-Transcript and Stop-Transcript commands to your script and see if it encounters an error.

    powershell-transcript-record-a-session-to-a-text-file

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.