VS Code PowerShell Configuration
vscode powershell windows development
Script Execution Permissions
PowerShell’s execution policy controls whether you can run scripts. By default, it’s often set to Restricted, which prevents running any scripts.
Changing the Execution Policy
| Action | Command | Scope | Recommendation |
|---|---|---|---|
| Check Policy | Get-ExecutionPolicy | N/A | Always check before making changes |
| Set Policy (Recommended) | Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | CurrentUser | Best balance of security and usability for development |
| Set Policy (Unrestricted) | Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser | CurrentUser | Avoid unless absolutely necessary (security risk) |
| Set Policy (Bypass) | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser | CurrentUser | Avoid unless absolutely necessary (security risk) |
Execution Policy Levels
| Policy | Description |
|---|---|
| Restricted | No scripts can run (default on Windows client) |
| AllSigned | Only scripts signed by a trusted publisher can run |
| RemoteSigned | Local scripts run freely; downloaded scripts need signature |
| Unrestricted | All scripts run with warning for downloaded scripts |
| Bypass | Nothing is blocked, no warnings |
Quick Commands
# Check current policy
Get-ExecutionPolicy
# Check policy for all scopes
Get-ExecutionPolicy -List
# Set recommended policy for development
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser