title: Cmdlet not recognized
body: <p>I wrote my first cmdlet. </p>
  
  <p>.\Scripts\Modules\NewShare\New-Share.psm1</p>
  
  <p>When I add .\Modules to $env:PSModulePath and I import the module, <strong>then I can retrieve the help</strong>, but I am not able to execute it.</p>
  
  <blockquote>
    <p>$evn:psmodulepath =
    C:\Users\bp\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;.\Modules;</p>
  </blockquote>
  
  <p>When I run the script </p>
  
  <pre><code>New-Share -foldername 'C:\MyShare' -sharename 'MyShare'
  </code></pre>
  
  <p>I get the following standard error, as the module doesn't exist. </p>
  
  <blockquote>
    <p>The term 'New-Share' 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:10
    + New-Share &lt;&lt;&lt;&lt;  -foldername 'C:\MyShare' -sharename 'MyShare'
        + CategoryInfo          : ObjectNotFound: (New-Share:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException</p>
  </blockquote>
  
  <p>What is the problem?</p>
  
  <p>My powershell module below.</p>
  
  <pre><code>function New-Share
  { 
      &lt;#
          .Synopsis
          This function create a new share
          .Description
          This function creates a new share. If the specified folder does not exist, it will be created, and then shared with the specified share name.
          .Example
          New-Share -foldername 'C:\MyShare' -sharename 'MyShare'
          Creates the share with name 'MyShare' for folder 'C:\MyShare'.
          .Parameter foldername
          The folder that needs to be shared. Will be created if it does not exist.
          .Parameter sharename
          The name for the share.
          #Requires PowerShell 2.0
      #&gt;
      [CmdletBinding()] 
       Param (
          [Parameter(Position=0, Mandatory=$True)] 
          [alias("fn")] 
          [string]$foldername, 
          [Parameter(Position=1, Mandatory=$True)] 
          [alias("sn")]
          [string]$sharename
          ) 
  
      if (!(test-path $foldername)) 
      { 
          new-item $foldername -type Directory 
      } 
  
      if (!(get-wmiObject Win32_Share -filter “name='$sharename'”)) 
      { 
          $shares = [WMICLASS]”WIN32_Share”
  
          if ($shares.Create($foldername, $sharename, 0).ReturnValue -ne 0) 
          {
              throw "Failed to create file share '$sharename'"
          }
      }
  }
  </code></pre>