If you dig down in task scheduler there are tons of examples to copy from. On Thu, Mar 7, 2013 at 1:08 PM, Crawford, Scott <crawfo...@evangel.edu>wrote:
> And one more note: > > Powershell "get-process" > Powershell -command "get-process" > > both dump the process list, but > > powershell -file "get-process" > > fails. > > -----Original Message----- > From: Crawford, Scott [mailto:crawfo...@evangel.edu] > Sent: Thursday, March 7, 2013 3:04 PM > To: NT System Admin Issues > Subject: RE: Running Powershell script as scheduled task fails with 0x1 > > Total guess coming :) > > It seems like -Command would be used when you just want to run a one liner > by passing the command directly, but -File is used when you want to run a > .ps1. > > That being said, I just did a quick test from cmd and all 3 of these are > equivalent (at least when the ps1 contains get-process): > > Powershell "c:\scripts\myscript.ps1" > Powershell -file "c:\scripts\myscript.ps1" > Powershell -command "c:\scripts\myscript.ps1" > > -----Original Message----- > From: Michael Leone [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> 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] > > 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 > > 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 > > > ~ 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 > > > ~ 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 > > ~ 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