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?


[string]. You should change your parameter definition to match the incoming type and then perform the parsing/conversion in the body of your function e.g.$ExcludeDaysString -split ","