2015-10-20 140 views
2

我嘗試使用自定義設置添加New-ScheduledTaskSettingsSet。根據Technet,MultipleInstances可能包括StopExisting值。Powershell新計劃任務設置集

enter image description here

但實際的PowerShell讓我只能選擇ParallelQueueIgnoreNew

爲什麼我不能使用StopExisting

+0

如果是從截圖和你使用的是什麼操作系統。 – Matt

+0

@Matt這是來自[TaskMultipleInstancesPolicy'枚舉的MSDN文檔](https://msdn.microsoft.com/en-us/library/microsoft.powershell.scheduledjob.taskmultipleinstancepolicy(v = vs.85)的屏幕截圖。 aspx) –

回答

4

如果你看一看的MultipleInstances屬性是如何定義的,你會看到,它的類型是實際上TaskMultipleInstancePolicy,但生成的類型命名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]);} 

這已經提交的bug on Microsoft Connect,如果您想更改它,請立即投票。

記者還提出了一種解決方法,以將值設置爲StopExisting

$StopExisting = New-ScheduledTaskSettingsSet 
$StopExisting.CimInstanceProperties['MultipleInstances'].Value=3 
+0

經過測試,像魅力一樣工作,謝謝!還增加了MS Connect票證。 – Pilskalns

+0

偉大的信息,一直在敲我的頭,試圖找出我失蹤的東西。 –

相關問題