New-ScheduledTaskAction : The term ‘New-ScheduledTaskAction’ is not recognized as the name of a cmdlet

Question:

My script is like-

but I am getting an error

Not sure what is wrong I tried to execute this powershell script to create a task in task scheduler to execute a bat file present in desktop

Answer:

With PowerShell 4.0 a scheduled task can be easily created with the new cmdlets New-ScheduledTaskAction, New-ScheduledTaskTrigger and Register-ScheduledTask, but unfortunately it’s not possible in the prévious versions (have a look to PSVersion in $PSVersionTable).

For previous version you can find many examples where people invoke the schtasks.exe command.

If you want to avoid calling external executables and do as much in PowerShell as possible you can use the Task Scheduler’s com object for creating a scheduled task.

Source:

New-ScheduledTaskAction : The term ‘New-ScheduledTaskAction’ is not recognized as the name of a cmdlet by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply