locked
Scheduling Powershell Task RRS feed

  • Question

  • I have a powershell script that runs via the task scheduler and is working correctly as long as the server (win2k8) is logged on.

    I have ticked the run whether user is logged on or not, but the task does not run the script and fails with

    Task Scheduler failed to start - Error Value: 2147943645 Event ID: 101

    If the server is logged on then everything runs fine. 

    Is there a problem running powershell in the backgroud if the user is not logged on ?

    The script is basically exporting my hyperv machines from one server to another for backup purposes.

    Any help appreciared

    Thanks

    Sean.

    Thursday, April 22, 2010 9:57 AM

Answers

  • Does the account you're using have the "logon as batch" user right?
    • Marked as answer by Mervyn Zhang Thursday, April 29, 2010 1:20 AM
    Thursday, April 22, 2010 12:44 PM
  • Also, make sure the account that you are using can run the script - when I have a problem I find that the account doesn't trust my security certificate, or has not had the execution policy correctly set, or a problem like that.

    My script account is a domain user

    On my script server (2008 R2), I created a group "Script Users", and put my script account in that group.

    That group is allowed to "allow log on locally" and "log on as a batch job" in secpol.msc "local policies"..."User Rights Assignment"

    That group has file level permissions on the hard drive as needed.

    Karl

     


    http://unlockpowershell.wordpress.com
    • Proposed as answer by Marco Shaw Friday, April 23, 2010 2:51 PM
    • Marked as answer by Mervyn Zhang Thursday, April 29, 2010 1:21 AM
    Thursday, April 22, 2010 2:20 PM

All replies

  • Do you have "Do not store password", or "Run with highest privileges" checked on security settings?

    Thursday, April 22, 2010 12:20 PM
  • No, neither of these are ticked.
    Thursday, April 22, 2010 12:39 PM
  • Does the account you're using have the "logon as batch" user right?
    • Marked as answer by Mervyn Zhang Thursday, April 29, 2010 1:20 AM
    Thursday, April 22, 2010 12:44 PM
  • Im using the domain admin id.  Where is the Logon as batch option ? is this within Task Scheduler ?
    Thursday, April 22, 2010 12:46 PM
  • Local Security Policy.
    Thursday, April 22, 2010 12:55 PM
  • Its set to Not Defined.  Do I need to turn this on ?
    Thursday, April 22, 2010 12:57 PM
  • I will only say that to run a scheduled task as a background job, the account it's running under must have that user right. 

     

    And that using the administrator account to run scheduled tasks is generally a really bad idea, because anyone who might be able to get to that script will be able to do whatever they want to the domain.

    Thursday, April 22, 2010 1:03 PM
  • Also, make sure the account that you are using can run the script - when I have a problem I find that the account doesn't trust my security certificate, or has not had the execution policy correctly set, or a problem like that.

    My script account is a domain user

    On my script server (2008 R2), I created a group "Script Users", and put my script account in that group.

    That group is allowed to "allow log on locally" and "log on as a batch job" in secpol.msc "local policies"..."User Rights Assignment"

    That group has file level permissions on the hard drive as needed.

    Karl

     


    http://unlockpowershell.wordpress.com
    • Proposed as answer by Marco Shaw Friday, April 23, 2010 2:51 PM
    • Marked as answer by Mervyn Zhang Thursday, April 29, 2010 1:21 AM
    Thursday, April 22, 2010 2:20 PM
  • Hi,

    Please try above suggestions and let us know if the issue continues. If it still occurs, please try to create a simple task, such as run Notepad, to replace the Powershell script to test.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, April 23, 2010 4:46 AM
  • Hi,

    Do you need any other assistance? If there is anything we can do for you, please let us know.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, April 29, 2010 1:21 AM