
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
- Right-click on any
.ps1
file. - Select “Open with” > “Choose another app”.
- Scroll down and click “More apps”.
- Find and select “Windows PowerShell”.
- Check the box “Always use this app to open .ps1 files”.
- 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)
- Open Command Prompt as Administrator.
- Associate
.ps1
with a custom file type:
assoc .ps1=Microsoft.PowerShellScript.1
- 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)
- Open Registry Editor (
regedit
). - Navigate to:
HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command
- Set the default value to:
-
"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.