我认为无论您使用什么操作系统,如果您安装了 Powershell,您都可以访问相同的默认 cmdlet。
所以我想用 Get-ScheduledTask在我的 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 的任何内容,所以我猜不是。
如果没有,那么是否会使用命令行:
scheduled task command line
毫无疑问,有人会指向我 this question但那是针对 Powershell 2 的。我使用的是 Powershell 4。
现在我是不重新发明轮子的忠实粉丝,但是这个 guys scripts看起来不错的选择。
最佳答案
Get-ScheduledTask
依赖于 Windows 7 没有的操作系统的底层功能,因此即使使用 PowerShell v4,也无法在该操作系统上运行 cmdlet。在您的情况下,您可以利用 schtasks.exe
或 Schedule.Service
COM 对象。
This answer您链接的内容提供了这些方法的最佳概述,但为了完整起见,我将在此处链接相关资源:
schtasks.exe
MS PowerShellPack TaskScheduler module ->(利用 Schedule.Service
COM 对象)
关于scheduled-tasks - Powershell 4 Get-ScheduledTask 和 Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26658249/