我认为无论您使用什么操作系统,如果安装了 Powershell,您都可以访问相同的默认 cmdlet。
所以我想用获取计划任务在我的 Windows 7 机器上。我安装了 Powershell 4。但是,当我运行它时,我收到错误:
Get-ScheduledTask : The term 'Get-ScheduledTask' is not recognized as the name
of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-ScheduledTask
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ScheduledTask:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
如果我在 Windows 8.1 上运行且已随操作系统一起预安装了 Powershell 4,则它可以正常工作。
我可以在 Windows 7 计算机上获取 cmdlet吗? Microsoft Get-ScheduledTask 页面上没有任何有关 Windows 7 的内容,所以我猜不是。
如果没有的话,那就是使用命令行的情况:
计划任务命令行
毫无疑问有人会指出我这个问题但这是针对 Powershell 2 的。我使用的是 Powershell 4。
现在我非常喜欢不要重新发明轮子,但是这个伙计们脚本看起来是一个不错的选择。
Get-ScheduledTask
依赖于 Windows 7 不具备的操作系统的底层功能,因此即使使用 PowerShell v4,也无法在该操作系统上运行 cmdlet。根据您的情况,您可以利用schtasks.exe
or the Schedule.Service
COM 对象。
这个答案您链接的内容提供了这些方法的最佳概述,但为了完整起见,我将在此处链接相关资源:
schtasks.exe
MS PowerShellPack TaskScheduler 模块->(利用Schedule.Service
COM 对象)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)