Is there a way to make a PowerShell script work by double clicking a .ps1 file? Is there a way to make a PowerShell script work by double clicking a .ps1 file? powershell powershell

Is there a way to make a PowerShell script work by double clicking a .ps1 file?


Create a shortcut with something like this as the "Target":

powershell.exe -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah"


Or if you want all PS1 files to work the way VBS files do, you can edit the registry like this:

HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\open\command

Edit the Default value to be something like so...

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -ExecutionPolicy unrestricted -file "%1"

Then you can just double click all your .PS1 files like you would like to. in my humble opinion, be able to out of the box.

I'm going to call this "The Powershell De-castration Hack". LOL enjoy!


This worked for me on Windows 10 and powershell 5.1:

  • right click on the .ps1 file
  • Open with...
  • Choose another app
  • Copy the location of powershell.exe to the address bar (by default it won't show windows folder) i.e. C:\Windows\System32\WindowsPowerShell\v1.0
  • select powershell.exe
  • select "Always use this app to open .ps1 files"
  • click OK