powershell - 计划任务未显示在 Get-ScheduledTask 结果中

标签 powershell scheduled-tasks octopus-deploy windows2012

我在“\”[默认] 路径下使用 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/

相关文章:

java - 如何每天下午 2 点运行 TimerTask?

octopus-deploy - 在八达通服务器上拉取但不部署 nuget 包

octopus-deploy - Octopus Deploy 可以有变量中的变量吗

powershell - powershell:从字符串末尾删除文本

java - Android Timer 时间表与 scheduleAtFixedRate

java - Spring-定时任务-优雅关机

containers - 添加 IBM Cloud Docker Registry 作为 Octopus Deploy 外部订阅源

mysql - 如何在 installshield 设置中运行/包含批处理文件

powershell - 使用 Add-Content PowerShell 将文本添加到现有文件的新行

powershell - 如何从 Powershell 运行这个 Beyond Compare 脚本?