2014-10-30 13 views
6

Ho pensato che indipendentemente dal sistema operativo in uso, se avessi installato Powershell, avresti accesso agli stessi cmdlet predefiniti.Powershell 4 Get-ScheduledTask e Windows

Quindi voglio usare Get-ScheduledTask sulla mia macchina Windows 7. Ho installato Powershell 4. Tuttavia, quando l'eseguo, ottengo l'errore:

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 

Se corro sul mio Windows PowerShell 8.1 con 4 già pre-installato con il sistema operativo, funziona.

Posso ottenere i cmdlet sul mio computer Windows 7? Non c'è nulla nella pagina Microsoft Get-ScheduledTask su Windows 7 quindi non sto indovinando.

Se poi non sarebbe che si tratti di un caso di usare la linea di comando:

scheduled task command line

Non c'è dubbio che qualcuno mi puntare a this question, ma che è stato per PowerShell 2. Sono in Powershell 4.

Ora sono un grande fan di non reinventare la ruota, ma questo guys scripts sembra una buona alternativa.

risposta

4

Get-ScheduledTask si affida alle funzionalità di base del sistema operativo che Windows 7 non ha, quindi non c'è modo di eseguire il cmdlet su quel sistema operativo, anche con PowerShell v4. Nel tuo caso, puoi sfruttare l'schtasks.exe o l'oggetto COM Schedule.Service.

This answer che si è collegato dà la migliore visione di questi metodi, ma nell'interesse della completezza, collegheremo le risorse rilevanti qui:

schtasks.exe

MS PowerShellPack TaskScheduler module -> (sfrutta l'oggetto Schedule.Service COM)