locked
PowerShell Question: Schtasks.exe Last Result -2147024894 RRS feed

  • Question

  • I'm trying to get a powershell to run via scheduled tasks.

    I created it to run a simple command:  powershell.exe c:\scripts\myscript.ps1.  It runs as administrator

    However every time I attempt to run it the task shows the last result is -2147024894.  Far as I can tell this means file was not found.

    I've tried creating a .cmd file with the above command and I get the same result.  Is there anyway I can see more details on why it's not running?


    Monday, March 7, 2016 2:05 PM

Answers

  • Hi Buffalo246,

    Thanks for posting on the TechNet forum.

    >> Far as I can tell this means file was not found. Is there anyway I can see more details on why it's not running?

    You could try to use the -FIle "c:\scripts\myscript.ps1"and run this command again.

    Enabled the history log to check the details information after you running the programs.

    More info, please refer to figures below:

                           Figure1: enabled the history logs

                             Figure2: configure the related settings

                              Figure3: success run the command

    Related info:

    https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script/

    Best regards,


    Andy_Pan






    • Edited by Hello_2018 Tuesday, March 8, 2016 3:08 AM
    • Proposed as answer by Hello_2018 Monday, March 14, 2016 9:06 AM
    • Marked as answer by Hello_2018 Tuesday, March 22, 2016 9:05 AM
    Tuesday, March 8, 2016 2:59 AM