Powershell 新计划任务设置集 [英] Powershell New-ScheduledTaskSettingsSet

查看:51
本文介绍了Powershell 新计划任务设置集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试添加

但实际的 powershell 只允许我选择 ParallelQueueIgnoreNew.

为什么我不能使用 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 新计划任务设置集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆