问题描述
我尝试添加
但实际的 powershell 只允许我选择 Parallel
、Queue
或 IgnoreNew
.
为什么我不能使用 StopExisting
?
如果你看看 MultipleInstances
属性是如何定义的,你会发现它的类型是 not 实际上 TaskMultipleInstancePolicy
,但生成的类型名为 MultipleInstancesEnum
:
PS C:\>(New-ScheduledTaskSettingsSet |Get-Member MultipleInstances).DefinitionSystem.Object MultipleInstances {get=[Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.MultipleInstancesEnum]($this.PSBase.CimInstanceProperties['MultipleInstances'].Value);set=$this.PSBase.CimInstanceProperties['MultipleInstances'].值 = [Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.MultipleInstancesEnum]($args[0]);}
这已作为Microsoft Connect 上的错误,如果您想更改它,请对其进行投票.
报告者还建议了一种解决方法,将值设置为 StopExisting
:
$StopExisting = New-ScheduledTaskSettingsSet$StopExisting.CimInstanceProperties['MultipleInstances'].Value=3
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
这篇关于Powershell 新计划任务设置集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!