Reputation: 6157
For a function I want to use an array of DayOfWeek
to exclude certain days from the automation script. For that I've setup the following function:
Param
(
[Parameter (Mandatory= $true)]
[ValidateNotNullOrEmpty()]
[DayofWeek[]] $ExcludeDays
)
foreach ($ExcludeDay in $ExcludeDays)
{
Write-Output $ExcludeDay
}
In the Azure testpane I've included the array as follows:
and this is the error it returns:
Failed
Cannot process argument transformation on parameter 'ExcludeDays'. Cannot convert value "Monday, Friday, Saturday" to type "System.DayOfWeek[]".
I've tried it simularly in Powershell by creating a function that takes the same parameter array and had no issue with similar input. Anybody knows how to get it working?
Upvotes: 1
Views: 4393
Reputation: 8151
You should pass them as ['Monday','Friday','Saturday']
. as Joy answered
another solution would be get input as Monday,Tuesday,Wednesday
and split it.
$CharArray = $InputString.Split(",")
Upvotes: 1