title: Calling PowerShell function from command line
body: <p>Given the following <code>say-hello.ps1</code> file on my file system:</p>
  
  <pre><code>function SayHello()
  {
      return "Hello World!"
  }
  </code></pre>
  
  <p>called on the command line like so (it will eventually run as a Windows Scheduled Task):</p>
  
  <pre><code>powershell -ExecutionPolicy unrestricted -command "&amp; { c:\say-hello.ps1; SayHello }"
  </code></pre>
  
  <p>Why am I getting the following result?</p>
  
  <pre><code>SayHello : The term 'SayHello' is not recognized as the name of a cmdlet,
  function, script file, or operable program. Check the spelling of the name, or
  if a path was included, verify that the path is correct and try again.
  At line:1 char:33
  + &amp; { c:\say-hello.ps1; SayHello }
  +                       ~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (SayHello:String) [], CommandNot
     FoundException
      + FullyQualifiedErrorId : CommandNotFoundException
  </code></pre>