How to Set .ps1 Files to Open with Windows PowerShell by Default

Published July 7, 2025
How to Set .ps1 Files to Open with Windows PowerShell by Default
Cheap Dedicated Server

Introduction

PowerShell scripts (.ps1 files) are essential for Windows system administration, automation, and scripting tasks. By default, Windows may associate .ps1 files with a text editor instead of executing them using PowerShell. In this guide, you’ll learn how to set .ps1 files to run by default with Windows PowerShell using simple steps.


Step-by-Step Guide

Option 1: Using File Properties

  1. Right-click on any .ps1 file.
  2. Select “Open with” > “Choose another app”.
  3. Scroll down and click “More apps”.
  4. Find and select “Windows PowerShell”.
  5. Check the box “Always use this app to open .ps1 files”.
  6. Click OK.

✅ Now, every time you double-click a .ps1 file, it will open in Windows PowerShell.


Option 2: Using ftype and assoc in CMD (Advanced)

  1. Open Command Prompt as Administrator.
  2. Associate .ps1 with a custom file type:
      Associate ps1 with a custom file type
    assoc .ps1=Microsoft.PowerShellScript.1
    
  3. Link that file type to PowerShell:
    Link that file type to PowerShell
    ftype Microsoft.PowerShellScript.1="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1" %*
    

🛠️ This sets the system-wide default program for .ps1 scripts to Windows PowerShell.


Option 3: Via Registry (For Advanced Users)

  1. Open Registry Editor (regedit).
  2. Navigate to:
    HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command
  3. Set the default value to:
  4. Set the default value to
  5. "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1" %*
    

⚠️ Be cautious with Registry edits—backup your registry first.


Conclusion

Associating .ps1 files with Windows PowerShell makes script execution much faster and smoother for developers and sysadmins. Whether you’re a beginner or a power user, choose the method that fits your comfort level.

Need to ensure scripts also run without warnings? Look into setting your Execution Policy using:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

 

How to Set .ps1 Files to Open with Windows PowerShell by Default (F.A.Q)

Why doesn’t my .ps1 file run on double-click?

 

By default, Windows opens .ps1 files in a text editor or blocks execution for security. You need to associate them with PowerShell manually.

Can I use PowerShell Core instead of Windows PowerShell?

Yes. Just replace the path with your PowerShell Core binary path (e.g., pwsh.exe).

 

Do I need admin rights to change the default program?

Yes, for system-wide changes via command line or registry. Right-click methods can be done without admin rights.

Can I revert back to Notepad or another app later?

Yes, repeat the “Open with” steps and choose your preferred application again.