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

ActionCommandScopeRecommendation
Check PolicyGet-ExecutionPolicyN/AAlways check before making changes
Set Policy (Recommended)Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserCurrentUserBest balance of security and usability for development
Set Policy (Unrestricted)Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUserCurrentUserAvoid unless absolutely necessary (security risk)
Set Policy (Bypass)Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUserCurrentUserAvoid unless absolutely necessary (security risk)

Execution Policy Levels

PolicyDescription
RestrictedNo scripts can run (default on Windows client)
AllSignedOnly scripts signed by a trusted publisher can run
RemoteSignedLocal scripts run freely; downloaded scripts need signature
UnrestrictedAll scripts run with warning for downloaded scripts
BypassNothing 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