Running powershell script from explorer = execution policy error

powershell

  1. In windows 7 final I've done: Set-ExecutionPolicy unrestricted
  2. In windows explorer, I select a script.ps1 file, select open with, put in c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe
  3. A powershell window flashes briefly with an error about execution policy.

Scripts run fine from within powershell. How can I run them from windows explorer?

Best Answer

Are you sure it's an execution policy error? If it's PowerShell v2, try including the -File parameter before the file name:

"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -File "%1"
Related Topic