簡體   English   中英

使用任務計划程序計划的Powershell腳本無法運行…腳本運行正常

[英]Powershell script scheduled using Task scheduler doesn't run…script runs fine

我正在使用Windows8。我有以下腳本文件(該腳本文件將我們所有的服務吐到CSV文件中)。 當我從powershell編輯器中按以下方式運行它時,它工作正常。

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

當我從Windows Task Scheduler調度此腳本時,它不會啟動。 我在該會話上設置了“無限制”執行策略。 以下是腳本文件中的代碼,並且兩個圖像是任務計划程序上的設置。

  #Trying out scheduling powershell scripts

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

動作

觸發

您必須使用-file參數。 只需輸入powershell-? 您將看到啟動Powershell的所有可能選項。

希望這會有所幫助-tom

在“編輯操作”對話框的“程序”框中,只需放入PowerShell 在參數中放入-file "C:\\sciptlocation\\scriptname.ps1"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM