title: Run powershell script as custom command inside cmd
body: <p>How can I run a PowerShell script as a custom command from cmd or powershell.</p>
  
  <p>For example my script (CreateFile.ps1):</p>
  
  <pre><code>function CreateFile ($fileName) {
      New-Item -Name $fileName -ItemType "file"    
  }
  
  CreateFile($args[0])
  </code></pre>
  
  <p>I would like to use the script in cmd\powershell with a custom command (here as "CF"):</p>
  
  <pre><code>C:\some folder&gt; CF testfile.txt
  </code></pre>
  
  <p>I added a new system environment variable with a link to my ps1 file. But it won't work, even after a reboot.</p>