Running PowerShell Script in Task Scheduler

I've looked through the entire PowerShell script in Task Scheduler answers in other questions and couldn't find one that resolves this.

I tried to run the PowerShell task manager script with direct access:

       powershell.exe -file c:\path_to_your_script\script.ps1


As well as creating a package to run a PowerShell script.

The PowerShell script works great when it is launched by itself, as well as when manually launching a package.

It opens Excel, refreshes it, saves and closes.

I cannot successfully schedule this through the task handler.

Any advice?

thanks for the help


@luke is the export of task scheduler settings

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="">
<Principal id="Author">
  <Actions Context="Author">
  <Arguments>/q /c "C:\Users\---------\Documents\PowerBI\PowerShell\RunExcelRefreshingScriptPowerShell2.bat"</Arguments>



source to share

2 answers

You can provide export of task schedule settings without username or password.

I have a lot of powershells that are run through the Task Scheduler and not one problem because I have my scheduler that is called by a bit that starts powershell.


and here you will find the result of the last run.



I had the same problem when I created a scheduled task to run the generated PowerShell script. I found that if you add the path to the Powershell.exe file (ie:% SystemRoot% \ system32 \ WindowsPowerShell \ v1.0 \ powershell.exe) in the Program / script window and the path to your actual PowerShell script (ie: D : \ Scripts \ PowershellScript.ps1) (see example below) in the Arguments window it will work. You will also need to check the Server PowerShell Execution Policy to make sure it is set to "unlimited". You can also try adding it as an argument (-ExecutionPolicy Bypass). Hope this helps someone. Example: Running PowerShell Scripts



All Articles