Powershell 4 Get-ScheduledTask and Windows

I thought that no matter what OS you had, if you had Powershell installed, you would have access to the same cmdlets by default.

So, I want to use Get-ScheduledTask on my Windows 7 machine. I have Powershell 4 installed. However, when I run it, I get an error message:

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 

If I run on my Windows 8.1 with Powershell 4 already installed with the OS installed, it works.

Can I get cmdlets on my windows 7 machine? There is nothing on the Microsoft Get-ScheduledTask page about Windows 7, so I don't think so.

If not, this will be a case of using the command line:

scheduled task command line

No doubt someone will point me to this question , but that was for Powershell 2. I'm on Powershell 4.

Now I am a big fan of not reinventing the wheel, but this scripts for guys look like a good alternative.

+6
source share
1 answer

Get-ScheduledTask relies on the basic OS features that Windows 7 does not have, so there is no way to run a cmdlet on this OS even with PowerShell v4. In your case, you can use schtasks.exe or the Schedule.Service COM object.

This answer you link gives a better overview of these methods, but in the interest of completeness I will link to the relevant resources here:

schtasks.exe

MS PowerShellPack TaskScheduler module β†’ - (uses the Schedule.Service COM object)

+4
source

Source: https://habr.com/ru/post/977486/


All Articles