我在“\”[默认] 路径下使用 Windows 任务计划程序 GUI 定义了一些计划任务,但是当我运行时 Get-ScheduledTask
在 powershell 中,它不会返回它们。为什么?
我试过 Get-ScheduledTask -TaskName "MyTaskName"
使用我的任务名称之一,但它出现“未找到属性‘TaskName’等于‘MyTaskName’的 MSFT_ScheduledTask 对象”
其实我试过https://library.octopusdeploy.com/step-template/actiontemplate-windows-scheduled-task-disable但它不起作用所以我尝试直接运行脚本。
更新
我找到了以下脚本来获取 http://www.fixitscripts.com/problems/getting-a-list-of-scheduled-tasks 上的任务列表:
# PowerShell script to get scheduled tasks from local computer
$schedule = new-object -com("Schedule.Service")
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks | Format-Table Name , LastRunTime # -AutoSize
IF($tasks.count -eq 0) {Write-Host “Schedule is Empty”}
Read-Host
预先感谢您的帮助。
最佳答案
通用汽车公司
结果很可能受UAC影响.要查看所有内容,请尝试右键单击 PowerShell 图标,选择 Run as Administrator
然后运行您的 Get-ScheduledTask
再次命令,看看是否有任何改变。
进一步阅读: http://david-homer.blogspot.co.uk/2017/10/not-all-scheduled-tasks-show-up-when.html
关于powershell - 计划任务未显示在 Get-ScheduledTask 结果中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42240783/