I always wrap powershell in a BAT and schedule the BAT. -----Original Message----- From: Michael Leone [mailto:[email protected]] Sent: Thursday, March 7, 2013 2:34 PM To: NT System Admin Issues Subject: Re: Running Powershell script as scheduled task fails with 0x1
Sorry; this is Win 2008 R2. On Thu, Mar 7, 2013 at 2:30 PM, Michael Leone <[email protected]> wrote: > I can't understand why my script is failing. I can run it from a > Powershell prompt (I have to "Run as administrator", because the > script is deleting some files in a backup directory). But it works > perfectly when I do it that way. But when I create a Scheduled Task to > do it, it fails with 0x1. > > I create a Task, tell it to use an account with domain admin > privileges. Tell it to run whether the user is logged on or not, and > to run with highest privileges The action calls a program > (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe). In "Add > arguments", I have > > -Command "C:\Scripts\myscript.ps1" > > And it always fails with 0x1. And I can't figure out why, if it is > running as a user with highest privileges and that works > interactively, from an elevated PS prompt. > > What part am I doing wrong? ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
