I have a function accepting an enum value as parameter. As an example, consider something like:
(PS) > function IsItFriday([System.DayOfWeek] $dayOfWeek) {
Yes, that is a rather confusing error message. I think you would understand better with an example:
Get-ChildItem -Path C:\
Notice there are no quotes around C:\
because, one, it implcitly gets converted to a string, and two, it is not necessary to enclose a path which does not contain spaces when you pass the path as a parameter to some callee.
So lets go back to your function, and change it slightly:
function IsItFriday($dayOfWeek)
{
$dayOfWeek.GetType()
if ($dayOfWeek -eq [System.DayOfWeek]::Friday)
{
"yes"
}
else
{
"no"
}
}
IsItFriday [System.DayOkWeek]::Monday
...and the output:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
no
See what happened there? PowerShell thinks you are passing in a string instead of an enumeration value, so that's why you get Cannot convert value "[System.DayOfWeek]::Monday"
because that is the literal string that gets passed in.