使用任务计划程序安排的Powershell脚本不运行...脚本运行正常

时间:2017-09-27 16:59:10

标签: windows powershell

我正在使用Windows 8。 我有以下脚本文件(将我们的所有服务吐出到CSV文件)。当我从PowerShell编辑器运行如下时,它工作正常。

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

当我从Windows任务计划程序安排此脚本时,它不会启动。 我有" Unrestricted"在该会话上设置的执行策略。以下是脚本文件中的代码,2个图像是任务计划程序中的设置。

  #Trying out scheduling powershell scripts

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

Actions

Trigger

2 个答案:

答案 0 :(得分:0)

您必须使用-file参数。只需输入powershell - ?并且您将看到启动PowerShell的所有可能选项。

希望这有助于-tom

答案 1 :(得分:0)

在“编辑操作”对话框的“程序”框中,只需输入PowerShell。在参数中放-file "C:\sciptlocation\scriptname.ps1"