Powershell 4 Get-ScheduledTask和Windows
问题描述:
我认为不管你有什么操作系统,如果你安装了Powershell,你可以访问相同的默认cmdlet。Powershell 4 Get-ScheduledTask和Windows
所以我想在我的Windows 7机器上使用Get-ScheduledTask。我安装了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
如果我使用PowerShell 4与操作系统一起已经预先安装在我的Windows 8.1上运行,它的工作原理。
我可以在我的Windows 7机器上获得cmdlet吗? Microsoft Get-ScheduledTask页面上没有关于Windows 7的内容,所以我猜测没有。
如果没有,那么会是使用命令行的情况:
毫无疑问,有人会指出我在this question但这是对PowerShell的2.我对PowerShell的4
现在我非常喜欢不重新发明轮子,但是这个guys scripts看起来不错。
答
Get-ScheduledTask
依赖于Windows 7没有的操作系统的基本功能,因此即使使用PowerShell v4,也无法在该操作系统上运行该cmdlet。在你的情况下,你可以利用schtasks.exe
或者Schedule.Service
COM对象。
This answer你链接给这些方法的最好的概述,但在完整性的利益,我会在这里链接相关的资源:
MS PowerShellPack TaskScheduler module - >(利用了Schedule.Service
COM对象)