Does anyone know of a powershell cmdlet out there for automating task scheduler in XP/2003? If you've ever tried to work w/ schtasks you know it's pretty painful.
有没有人知道PowerShell cmdlet在XP / 2003中自动执行任务调度程序?如果你曾经尝试过与schtasks一起工作,你知道这很痛苦。
6 个解决方案
#1
3
Ok, Pablo has sparked my interest in saying that the scheduler is accessible via COM.
好吧,Pablo引起了我的兴趣,说可以通过COM访问调度程序。
In PowerShell you can do this:
在PowerShell中,您可以这样做:
$svc = new-object -com Schedule.Service
... and that gives you a handle to the task scheduler. You can see what members it has using:
...它为您提供了任务计划程序的句柄。您可以看到它使用的成员:
$svc | get-member
One of its methods is NewTask, so I'd start there.
其中一个方法是NewTask,所以我从那里开始。
Edit: Some more info here. It's a VBScript example but it'll give you the gist.
编辑:这里有更多信息。这是一个VBScript示例,但它会给你一个要点。
#2
1
You don't need PowerShell to automate the Task Scheduler, you can use the SCHTASKS command in XP.
您不需要PowerShell来自动执行任务计划程序,您可以在XP中使用SCHTASKS命令。
According to Wikipedia, the Task Scheduler 2.0 (Vista and Server 2008) is accesible via COM.
根据*,Task Scheduler 2.0(Vista和Server 2008)可通过COM访问。
#3
1
This is a good article (be sure to read the other linked article in it) that discusses looking at th scheduled tasks on remote machines. It is not exactly what you were asking for but it should get you headed in the right direction.
这是一篇很好的文章(请务必阅读其中的其他链接文章),讨论查看远程计算机上的计划任务。这不完全是你所要求的,但它应该让你朝着正确的方向前进。
#4
1
@(EBGreen) Win32_ScheduledJob class only works with at-scheduled jobs.
@(EBGreen)Win32_ScheduledJob类仅适用于预定作业。
Windows 2000和Windows NT 4.0:您可以使用“计划任务”UI修改最初使用WMI创建的任务。但是,尽管已成功修改任务,但您无法再使用WMI访问任务。
The other solution using the com object Schedule.Service is also not an option for 2003
使用com对象Schedule.Service的另一个解决方案也不是2003的选项
the question is can we use script, PowerShell in particular to retrieve the tasks scheduled using Task Scheduler API? Yes, we can! But you will need Windows Vista to accomplish that.
问题是我们可以使用脚本,特别是PowerShell来检索使用Task Scheduler API计划的任务吗?我们可以!但是你需要Windows Vista来实现这一目标。
cheers
#5
0
Not "native" PowerShell, but if you're running powershell.exe as an administrator then you should have access to the "at" command, which you can use to schedule tasks.
不是“本机”PowerShell,但如果您以管理员身份运行powershell.exe,则应该可以访问“at”命令,您可以使用该命令来安排任务。
#6
-1
@slipsec: I don't have access to a 2003 server to try, but googling "2003 server" SCHTASKS there are links related to questions about it. Perhaps you misspell the command? Like Matt says, you also can use AT, but in this case you don't have access to the scheduled tasks via the Control Panel, only via the AT command.
@slipsec:我没有访问2003服务器的尝试,但谷歌搜索“2003服务器”SCHTASKS有关于它的问题的链接。也许你拼错了命令?像Matt所说,你也可以使用AT,但在这种情况下,你无法通过控制面板访问计划任务,只能通过AT命令。
#1
3
Ok, Pablo has sparked my interest in saying that the scheduler is accessible via COM.
好吧,Pablo引起了我的兴趣,说可以通过COM访问调度程序。
In PowerShell you can do this:
在PowerShell中,您可以这样做:
$svc = new-object -com Schedule.Service
... and that gives you a handle to the task scheduler. You can see what members it has using:
...它为您提供了任务计划程序的句柄。您可以看到它使用的成员:
$svc | get-member
One of its methods is NewTask, so I'd start there.
其中一个方法是NewTask,所以我从那里开始。
Edit: Some more info here. It's a VBScript example but it'll give you the gist.
编辑:这里有更多信息。这是一个VBScript示例,但它会给你一个要点。
#2
1
You don't need PowerShell to automate the Task Scheduler, you can use the SCHTASKS command in XP.
您不需要PowerShell来自动执行任务计划程序,您可以在XP中使用SCHTASKS命令。
According to Wikipedia, the Task Scheduler 2.0 (Vista and Server 2008) is accesible via COM.
根据*,Task Scheduler 2.0(Vista和Server 2008)可通过COM访问。
#3
1
This is a good article (be sure to read the other linked article in it) that discusses looking at th scheduled tasks on remote machines. It is not exactly what you were asking for but it should get you headed in the right direction.
这是一篇很好的文章(请务必阅读其中的其他链接文章),讨论查看远程计算机上的计划任务。这不完全是你所要求的,但它应该让你朝着正确的方向前进。
#4
1
@(EBGreen) Win32_ScheduledJob class only works with at-scheduled jobs.
@(EBGreen)Win32_ScheduledJob类仅适用于预定作业。
Windows 2000和Windows NT 4.0:您可以使用“计划任务”UI修改最初使用WMI创建的任务。但是,尽管已成功修改任务,但您无法再使用WMI访问任务。
The other solution using the com object Schedule.Service is also not an option for 2003
使用com对象Schedule.Service的另一个解决方案也不是2003的选项
the question is can we use script, PowerShell in particular to retrieve the tasks scheduled using Task Scheduler API? Yes, we can! But you will need Windows Vista to accomplish that.
问题是我们可以使用脚本,特别是PowerShell来检索使用Task Scheduler API计划的任务吗?我们可以!但是你需要Windows Vista来实现这一目标。
cheers
#5
0
Not "native" PowerShell, but if you're running powershell.exe as an administrator then you should have access to the "at" command, which you can use to schedule tasks.
不是“本机”PowerShell,但如果您以管理员身份运行powershell.exe,则应该可以访问“at”命令,您可以使用该命令来安排任务。
#6
-1
@slipsec: I don't have access to a 2003 server to try, but googling "2003 server" SCHTASKS there are links related to questions about it. Perhaps you misspell the command? Like Matt says, you also can use AT, but in this case you don't have access to the scheduled tasks via the Control Panel, only via the AT command.
@slipsec:我没有访问2003服务器的尝试,但谷歌搜索“2003服务器”SCHTASKS有关于它的问题的链接。也许你拼错了命令?像Matt所说,你也可以使用AT,但在这种情况下,你无法通过控制面板访问计划任务,只能通过AT命令。