I am trying to achieve the following settings (select "If the task is already running, then the following rule applies") through PowerShell script but unable to get appropriate settings to configure that.
I am using the following code to configure that
$Trigger = New-ScheduledTaskTrigger -At 07:00am -Daily
$Settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hour 1) -Compatibility Win7 -StartWhenAvailable -Priority 7
$User = "SYSTEM"
$Action = New-ScheduledTaskAction -Execute "some script" -Argument "some argument" -WorkingDirectory "working dir"
Register-ScheduledTask -TaskName "Test Task" -Trigger $Trigger -User $User -Action $Action -Settings $Settings -RunLevel Highest –Force
To do the advanced configuration for the triggers
$Task = Get-ScheduledTask -TaskName "Example Task"
$Task.Triggers[0].ExecutionTimeLimit = "PT10M"
$Task | Set-ScheduledTask -User $User

The setting is configured via
New-ScheduledTaskSettingsSetand the parameter you're looking for is-MultipleInstances:However, the documentation lists only 3 values, and the respective enum (at least at the time of this writing also only has the listed 3 values:
Parallel→ Run a new instance in parallelQueue→ Queue a new instanceIgnoreNew→ Do not start a new instanceIf you create a task manually via the GUI and select the setting "Stop the existing instance" the value
.Settings.MultipleInstancesis empty, but if you create a Settings object viaNew-ScheduledTaskSettingsSetomitting the parameter-MultipleInstancesit defaults toIgnoreNew. Attempts to change that to an empty value result in validation errors.This is obviously a bug (missing value in the referenced enum).