Issue Running PowerShell on Windows Task Scheduler
NickName:Harif87 Ask DateTime:2018-08-06T01:03:27

Issue Running PowerShell on Windows Task Scheduler

I'm trying to run a PowerShell command via Task Scheduler but keep getting the below result when the task tries to run PowerShell on my Windows Server 2008 R2 environment.

action "powershell.exe" with return code 1.

When I run the script in PowerShell manually, the script runs. But for some reason, when I call it from the Task Scheduler it doesn't run.

A screenshot of how my action is set up is attached below.

I've made sure to do the following:

  1. Set ExecutionPolicy to RemoteSigned
  2. Set task to run with highest priveleges
  3. Set task to run whether user logged on or not
  4. Set task configuration for Windows 7, Windows Server 2008 R2

I'm fresh out of ideas.

enter image description here

Copyright Notice:Content Author:「Harif87」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51696465/issue-running-powershell-on-windows-task-scheduler

Answers
Harif87 2018-08-07T13:06:22

Figured this one out thanks to some help from @TheIncorrigible1.\n\nThe issue was that the Start In field on the task scheduler was set to a path with a root directory other than C:\n\nTo resolve, I left Start In blank and in the Add Arguments field I called the script file with a full file path. \n\nInstead of the below in the Add Arguments field\n\n.\\csv-convert.ps1\n\n\nI referenced the script as follows :\n\nD:\\mypath\\csv-convert.ps1\n\n\nBottom line, dont start powershell in a path with a directory other than C:",


More about “Issue Running PowerShell on Windows Task Scheduler” related questions

Issue with windows task scheduler with running a powershell script in windows 2008 server

This question would seem a very common question but i have done every possible thing for the solution but nothing works for me. I m trying to run a powershell script via batch powershell.exe c:\

Show Detail

Issue Running PowerShell on Windows Task Scheduler

I'm trying to run a PowerShell command via Task Scheduler but keep getting the below result when the task tries to run PowerShell on my Windows Server 2008 R2 environment. action "powershe...

Show Detail

PowerShell script running as different user in Windows Task Scheduler

I am trying to configure a PowerShell script which will run in Windows Task Scheduler for multiple service accounts. I found a way to run the PowerShell script with a given user via the 2nd answer...

Show Detail

Powershell and task scheduler

I am having a strange issue with task scheduler on my Win 7 machine not properly running a Powershell script which is supposed to email me a PDF file daily. If I run the script manually via ISE......

Show Detail

Running Windows Powershell script always from task scheduler

This might be a very basic question. I have FileWatcher script in windows powershell which I want to run always so that it keeps watching a particular location for files. when I run it from Windows

Show Detail

Windows Task Scheduler not running task despite trigger

please keep in mind throughout this that I am quite new to windows automation and powerShell so go easy on me please. My goal was to create an automatic USB cloner in order to copy files if the dri...

Show Detail

Windows Task Scheduler is not working on Cluster through powershell

I have configured the windows task scheduler with any node type using powershell commands in the cluster as Active/Passive. If one system goes down, the task scheduler is switching to another node ...

Show Detail

Powershell Task Scheduler Stuck Running

I was trying to test a simple powershell script with task scheduler, the status showed running but the powershell console never showed up. My ps1 script just contains two simple commands: dir pa...

Show Detail

Logfile not being generated while running a powershell script with windows task scheduler

I have created the following powershell script: stop-service ''3456'' start-sleep -s 60 stop-service "2354" start-sleep -s 60 Restart-computer QY34 -Force send -mailmessag

Show Detail

How to redirect powershell output within batch file ( when run from Task Scheduler)?

i'm running a batch file from Task Scheduler wich i excecute a Powershell Scripts. So , i have a batch file (TestFD.bat) : Powershell -Command "& {C:\Users\csadouni\Desktop\testFDCOMM.ps1}" &...

Show Detail