Skip to content

Commit 5fcea34

Browse files
committed
feat: Add troubleshooting guide for PowerShell execution policy errors
1 parent 0458177 commit 5fcea34

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# PowerShell Execution Policy Error
2+
3+
## Problem
4+
5+
When running `phat` commands, you see this error:
6+
7+
```
8+
phat : File C:\Program Files (x86)\Phat\phat.ps1 cannot be loaded. The file C:\Program Files (x86)\Phat\phat.ps1 is
9+
not digitally signed. You cannot run this script on the current system. For more information about running scripts and
10+
setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
11+
At line:1 char:1
12+
+ phat
13+
+ ~~~~
14+
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
15+
+ FullyQualifiedErrorId : UnauthorizedAccess
16+
```
17+
18+
## Cause
19+
20+
Windows PowerShell has an execution policy that prevents unsigned scripts from running. By default, Windows blocks all scripts for security reasons.
21+
22+
## Solutions
23+
24+
### Solution 1: Set Execution Policy (Recommended)
25+
26+
This is the recommended approach that balances security and functionality.
27+
28+
**Step 1:** Open PowerShell as Administrator
29+
- Press `Win + X` and select "Windows PowerShell (Admin)" or "Terminal (Admin)"
30+
31+
**Step 2:** Set the execution policy
32+
```powershell
33+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
34+
```
35+
36+
When prompted, type `Y` and press Enter.
37+
38+
**Step 3:** Unblock the script file
39+
```powershell
40+
Unblock-File "C:\Program Files (x86)\Phat\phat.ps1"
41+
```
42+
43+
**Step 4:** Test the installation
44+
```powershell
45+
phat --version
46+
```
47+
48+
### Solution 2: Unblock File Only
49+
50+
If your execution policy is already set but the script is still blocked:
51+
52+
```powershell
53+
Unblock-File "C:\Program Files (x86)\Phat\phat.ps1"
54+
```
55+
56+
### Solution 3: Bypass for Current Session
57+
58+
If you only need to run Phat temporarily:
59+
60+
```powershell
61+
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
62+
```
63+
64+
This only affects the current PowerShell session and doesn't make permanent changes.
65+
66+
## Understanding Execution Policies
67+
68+
| Policy | Description |
69+
|--------|-------------|
70+
| **Restricted** | No scripts allowed (Windows default) |
71+
| **RemoteSigned** | Local scripts run; downloaded scripts need signature (Recommended) |
72+
| **Unrestricted** | All scripts run with warnings for downloaded ones |
73+
| **Bypass** | Nothing blocked, no warnings |
74+
75+
## Check Current Policy
76+
77+
To see your current execution policy settings:
78+
79+
```powershell
80+
Get-ExecutionPolicy -List
81+
```
82+
83+
## Why RemoteSigned is Recommended
84+
85+
- **Security**: Downloaded scripts still require a digital signature
86+
- **Functionality**: Your own local scripts (like Phat) can run without issues
87+
- **Balance**: Provides protection against malicious downloaded scripts while allowing legitimate local development
88+
89+
## Related Resources
90+
91+
- [PowerShell Execution Policies Documentation](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies)
92+
- [Back to Troubleshooting Index](TROUBLESHOOTING.md)

0 commit comments

Comments
 (0)