Vítek S.
Vítek S.

Reputation: 29

New-ScheduledTaskTrigger -AtLogon repetition

I have a problem with setting New-ScheduledTaskTrigger cmdlet with parameter -AtLogon. In UI there is a option how often I want to repeat the action, and more other options what to set. But in PowerShell I don't have this parameters. How can I set this parameter in PowerShell?

Upvotes: 2

Views: 2188

Answers (1)

Richard
Richard

Reputation: 7000

You can use the New-ScheduledTaskTrigger cmdlet with both -AtStartup & -AtLogon to create the trigger object. Then simply update the object with your required repetition values. In this example I have set the task to repeat every 5 minutes for and hour after logon.

$trigger = New-ScheduledTaskTrigger -AtLogOn
$trigger.RepetitionDuration = (New-TimeSpan -Hours 1)
$trigger.RepetitionInterval = (New-TimeSpan -Minutes 5)
$trigger | select *

Upvotes: 2

Related Questions