gpt4 book ai didi

azure - 在 Azure 自动化 Powershell 脚本中使用参数数组

转载 作者:行者123 更新时间:2023-12-03 04:49:38 26 4
gpt4 key购买 nike

对于一个函数,我想使用 DayOfWeek 数组从自动化脚本中排除某些日子。为此,我设置了以下功能:

Param
(
[Parameter (Mandatory= $true)]
[ValidateNotNullOrEmpty()]
[DayofWeek[]] $ExcludeDays
)

foreach ($ExcludeDay in $ExcludeDays)
{
Write-Output $ExcludeDay
}

在 Azure 测试面板中,我已包含该数组,如下所示:

Input example

这是它返回的错误:

Failed
Cannot process argument transformation on parameter 'ExcludeDays'. Cannot convert value "Monday, Friday, Saturday" to type "System.DayOfWeek[]".

我已经在 Powershell 中进行了类似的尝试,方法是创建一个采用相同参数数组的函数,并且对于类似的输入没有任何问题。有人知道如何让它工作吗?

最佳答案

您应该将它们传递为['Monday','Friday','Saturday']

enter image description here

关于azure - 在 Azure 自动化 Powershell 脚本中使用参数数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57034499/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com