1

I am using windows 8. I have the following script file (that spits our all services to a CSV file). When I run this as follows from powershell editor, it works fine.

 C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe C:\Powershell\SchedulingaScript.ps1

When I schedule this script from windows task scheduler it won't kick off. I have "Unrestricted" execution policy set on that session. Following is the code in the script file and 2 images are the setting on the task scheduler.

  #Trying out scheduling powershell scripts

  Get-Service | Export-CSV "C:\ExportingServicestoaCSVFile.CSV"

Actions

Trigger

2 Answers 2

1

You have to use the -file Parameter. Simply enter powershell -? and you will see all possible options to launch powershell.

Hope this helps -tom

Sign up to request clarification or add additional context in comments.

2 Comments

I tried with -File also. It runs fine at Powershell prompt. But not from Windows task scheduler
Simply put "powershell.exe" in the Program/Script field (without path). If this doesn´t help try to start the script from a cmd prompt starting with powershell.exe and appending the parameters.
0

In the Edit Action dialog Program box simply put PowerShell. In Arguments put -file "C:\sciptlocation\scriptname.ps1"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.