Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PowerShell Task Scheduler Not Working

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello Can anyone point out what is wrong with my powershell not executed from Task Scheduler.
Though manual execution works. Here is the content of the script:

AGV213_lasmrj.jpg


However, in Task Scheduler it does not work even though the history says successful

below is the General Tab in Scheduler
AGV213104JJ_djqsuh.jpg


below is the trigger
AGV21310445_nwwooq.jpg


below is the action
AGV21310446_zfqjyu.jpg


Condition. Note this was default.
AGV21310448_njkqr8.jpg


Settings
AGV213104450_jncpey.jpg


History
AGV213104408_tggsog.jpg
 
See if this helps:

At the part where it suggests adding the argument "-ExecutionPolicy Bypass", you may actually need more than that. I use "-nologo -executionpolicy bypass -windowstyle hidden -file" when I execute it from a command line, which looks something like:

[tab]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -executionpolicy bypass -windowstyle hidden -file "C:\Folder\MyScript.ps1"


The parameter "-windowstyle hidden" is completely optional, especially if you're running it on a server.

-Carl
"The glass is neither half-full nor half-empty: it's twice as big as it needs to be."

[tab][navy]For this site's posting policies, click [/navy]here.
 
Confirm cdogg suggestion though we've "got away" with just powershell.exe -executionpolicy bypass -file "j:.........\script.ps1" Script parameters can also be passed in via the Add Arguments option.
Also make sure any account passwords are correct as it doesnt seem to advise if incorrect
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top