Sorry to reply out of thread order (dont have the original). No need to sigh, ditch the bad posts on the net and run `powershell /?`
A ps1 "file" is not a command. You need to invoke the "script". -----Original Message----- From: Michael Leone [mailto:oozerd...@gmail.com<mailto:oozerd...@gmail.com>] Sent: Thursday, March 7, 2013 1:59 PM To: NT System Admin Issues Subject: Re: Running Powershell script as scheduled task fails with 0x1 On Thu, Mar 7, 2013 at 2:37 PM, Webster <webs...@carlwebster.com<mailto:webs...@carlwebster.com>> wrote: > I thought it was -File "c:\scripts\myscript.ps1". See, this is what's infuriating. Most of the examples I have found say you don't need "-Command" or "-File". Some say "-Command". Some say the 2 are equivalent. <SIGH> So I changed it to "-File", and made sure the folder holding the script itself had no spaces in its name. And then it all started working ... I thought for sure I had tried it with "-File" as well, but maybe not. Anyways, it all seems good now. Thanks. > > > Carl Webster > Consultant and Citrix Technology Professional > http://www.CarlWebster.com > > > -----Original Message----- > From: Michael Leone [mailto:oozerd...@gmail.com<mailto:oozerd...@gmail.com>] > Sent: Thursday, March 07, 2013 2:30 PM > To: NT System Admin Issues > Subject: Running Powershell script as scheduled task fails with 0x1 > > 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" > > > > > ~ 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 > listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> > 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> 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 listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe ntsysadmin