scheduled-tasks - Powershell 4 Get-ScheduledTask 和 Windows

标签 scheduled-tasks powershell-4.0

我认为无论您使用什么操作系统,如果您安装了 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.exeSchedule.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/

相关文章:

windows - 从非交互式进程(Windows 服务、计划任务等)在 WinServer 2008 中打印 PDF

powershell - 刷新 PowerShell DSC 资源

PowerShell:Start-Job 中的 $input 到底是什么?

windows - 用于创建具有属性的快捷方式的 Powershell 脚本

c# - 遍历类的静态属性

java - 计划的 Cron 运行超出 Spring Boot 中规定的时间

windows - 如何使用每月多天的 schtasks.exe 创建任务

c# - 使用 C# TaskScheduler 库创建的 .job 文件在 Windows 7 中是否已过时?

windows - 创建并立即运行一次 Windows 任务(以管理员身份)

powershell - 将选定项目从一个文件夹复制到新文件夹