Reputation: 557
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"
Upvotes: 1
Views: 2914
Reputation: 917
In the Edit Action dialog Program box simply put PowerShell
. In Arguments put -file "C:\sciptlocation\scriptname.ps1"
Upvotes: 0
Reputation: 188
You have to use the -file Parameter. Simply enter powershell -? and you will see all possible options to launch powershell.
Hope this helps -tom
Upvotes: 1