1

I'm trying to create a bat file to modify a scheduled task setting, for this I have tried these two methods (A-B):

.BAT

powershell -executionpolicy Unrestricted -File C:\Temp\config\tasks.ps1

A) tasks.ps1

$settingsSet = New-ScheduledTaskSettingsSet
$settingsSet.ExecutionTimeLimit = 'PT0S'
Set-ScheduledTask -TaskName TaskStart -Settings $settingsSet

B) tasks.ps1

$task = Get-ScheduledTask "TaskStart"
$task.Settings.ExecutionTimeLimit = "PT0S"
Set-ScheduledTask $task

both work in w10, but in w7 I have the same error:

The term '***' 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."

How can you make this in w7? I would like to know how to modify the ExecutionTimeLimit.

Thanks in Advance

  • 1
    Does this answer your question? [Powershell 4 Get-ScheduledTask and Windows](https://stackoverflow.com/questions/26658249/powershell-4-get-scheduledtask-and-windows) – boxdog Jul 15 '20 at 09:50
  • not exactly, it's not clear – Enrico Mangani Jul 15 '20 at 10:28
  • Basically, what it's saying is that `Get-ScheduledTask` won't ever work on Windows 7 because the cmdlet relies on some underlying OS component that is not present on that version of the OS. You will need to use an alternative, such as `schtasks.exe`. There is a little more detail in this other question: [Get-ScheduledTask command does not work in Windows Server 2008 R2](https://stackoverflow.com/questions/51147611/get-scheduledtask-command-does-not-work-in-windows-server-2008-r2/51147933) – boxdog Jul 15 '20 at 10:40
  • I would like to know how to modify the ExecutionTimeLimit, not how to use the Get-ScheduledTask – Enrico Mangani Jul 15 '20 at 12:59

0 Answers0