I try to add New-ScheduledTaskSettingsSet with custom settings. As per Technet, there is possible options for MultipleInstances and including StopExisting value.

But actual powershell allows me choose only Parallel, Queue or IgnoreNew.
Why I can't use StopExisting?
If you take a look how the MultipleInstances property is defined, you'll see that it's type is not actually TaskMultipleInstancePolicy, but a generated type named MultipleInstancesEnum:
PS C:\>(New-ScheduledTaskSettingsSet |Get-Member MultipleInstances).Definition
System.Object MultipleInstances {get=[Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.MultipleInstancesEnum]($this.PSBase.CimInstanceProperties['MultipleInstances'].Value);set=$this.PSBase.CimInstanceProperties['MultipleInstances'].Value = [Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.MultipleInstancesEnum]($args[0]);}
This has been filed as a bug on Microsoft Connect, upvote it if you want it changed.
The reporter also suggests a workaround to set the value to StopExisting:
$StopExisting = New-ScheduledTaskSettingsSet
$StopExisting.CimInstanceProperties['MultipleInstances'].Value=3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With