title: Passing enum values to a function in PowerShell
body: <p>I have a function accepting an enum value as parameter. As an example, consider something like:</p>
  
  <pre><code>(PS) &gt; function IsItFriday([System.DayOfWeek] $dayOfWeek) { 
      if($dayOfWeek -eq [System.DayOfWeek]::Friday) {
          "yes"
      } else {
          "no"
      } 
  }
  </code></pre>
  
  <p>Now, if I invoke it like this, everything is fine:</p>
  
  <pre><code>(PS) &gt; $m = [System.DayOfWeek]::Monday
  (PS) &gt; IsItFriday $m
  no
  </code></pre>
  
  <p>But if I call the function passing directly the enum value, I get a rather cryptic error:</p>
  
  <pre><code>(PS) &gt; IsItFriday [System.DayOfWeek]::Monday
  IsItFriday : Cannot convert value "[System.DayOfWeek]::Monday" to type "System.DayOfWeek" 
  due to invalid enumeration values. Specify one of the following enumeration values and 
  try again. The possible enumeration values are "Sunday, Monday, Tuesday, Wednesday, 
  Thursday, Friday, Saturday".
  At line:1 char:11
  + IsItFriday  &lt;&lt;&lt;&lt; [System.DayOfWeek]::Monday
  </code></pre>
  
  <p>What's the difference between initializing a variable with the enum value and passing the enum value directly?</p>