2014-10-30 56 views
6

我認爲不管你有什麼操作系統,如果你安裝了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的內容,所以我猜測沒有。

如果沒有,那麼會是使用命令行的情況:

scheduled task command line

毫無疑問,有人會指出我在this question但這是對PowerShell的2.我對PowerShell的4

現在我非常喜歡不重新發明輪子,但是這個guys scripts看起來不錯。

回答

4

Get-ScheduledTask依賴於Windows 7沒有的操作系​​統的基本功能,因此即使使用PowerShell v4,也無法在該操作系統上運行該cmdlet。在你的情況下,你可以利用schtasks.exe或者Schedule.Service COM對象。

This answer你鏈接給這些方法的最好的概述,但在完整性的利益,我會在這裏鏈接相關的資源:

schtasks.exe

MS PowerShellPack TaskScheduler module - >(利用了Schedule.Service COM對象)