gpt4 book ai didi

powershell - 如何批量启用任务

转载 作者:行者123 更新时间:2023-12-02 23:12:41 24 4
gpt4 key购买 nike

我在Windows任务库中有很多任务。
我需要一次性启用它们。

现在,我必须单独进行操作,这不是可行的解决方案。

现在,我的代码如下所示:

$task_name="Imported Task"
$task_path="\myTasks\"
Enable-ScheduledTask -TaskName $task_name -TaskPath $task_path

我搜索了谷歌,但没有帮助。

最佳答案

使用scheduler com对象:

$computername="localhost"
$sch = New-Object -ComObject("Schedule.Service")
$sch.connect($computername)
$root=$sch.GetFolder("\")
$folder =$sch.GetFolder("\myTasks")
$folder.GetTasks(0) |%{$_.enabled=$true}

关于powershell - 如何批量启用任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32579188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com