Skip to content

Setting PowerShell 7 as Default Shell

This guide explains how to make PowerShell 7 your default shell in Windows, replacing Windows PowerShell (version 5.1) for both File Explorer context menus and Windows Terminal.

Problem Overview

When you right-click in File Explorer and select "Open PowerShell window here," Windows typically opens Windows PowerShell 5.1 instead of the newer PowerShell 7. Users may also want to configure Windows Terminal to default to PowerShell 7 instead of other installed shells.

Solution 1: Configure Windows Terminal Default Profile

Windows Terminal allows you to easily set PowerShell 7 as your default shell through its settings interface:

  1. Open Windows Terminal
  2. Click the dropdown arrow and select Settings
  3. In the General tab, locate the Default profile dropdown
  4. Select the PowerShell 7 profile (typically shows the PowerShell icon, not the Windows PowerShell icon)
  5. Click Save and restart Windows Terminal

INFO

If you don't see PowerShell 7 in the profiles list, you may need to install it first from the Microsoft Store or the GitHub releases page.

Manual JSON Configuration (Advanced)

For users who prefer manual configuration or need to troubleshoot:

  1. In Windows Terminal Settings, click Open JSON file
  2. Locate the defaultProfile setting near the top
  3. Find the GUID for your PowerShell 7 profile (look for entries with "source": "Windows.Terminal.PowershellCore")
  4. Replace the current defaultProfile value with the PowerShell 7 GUID
  5. Save the JSON file
json
{
  "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
  // ... other settings
}

Solution 2: Replace File Explorer Context Menu

To change the "Open PowerShell window here" action in File Explorer to use PowerShell 7:

Using Registry Editor

  1. Press Win + R, type regedit, and press Enter
  2. Navigate to: HKEY_CLASSES_ROOT\Directory\shell\Powershell\command
  3. Double-click on the (Default) value
  4. Change the data to: "C:\Program Files\PowerShell\7\pwsh.exe" -NoExit -Command "Set-Location '%V'"
powershell
# Alternative: Use PowerShell to modify the registry
$pwshPath = "C:\Program Files\PowerShell\7\pwsh.exe"
Set-ItemProperty -Path "HKCR:\Directory\shell\Powershell\command" -Name "(Default)" -Value "`"$pwshPath`" -NoExit -Command `"Set-Location '%V'`""

Warning

Editing the registry incorrectly can cause system instability. Always back up your registry before making changes.

For Windows 11 Users

Windows 11 changed the context menu behavior:

  1. Install PowerShell 7 from the Microsoft Store
  2. The newer "Open in Terminal" option should automatically use your Windows Terminal default profile
  3. Alternatively, use third-party tools like Chris Titus's WinUtil to modify context menus

Solution 3: Troubleshooting Common Issues

App Execution Alias Problem

If PowerShell 7 doesn't work after configuration:

  1. Open Settings > Apps > Advanced app settings
  2. Select App execution aliases
  3. Ensure the Terminal alias is enabled for wt.exe

Multiple PowerShell Installations

To remove older PowerShell versions:

  1. Open Settings > Apps > Apps & features
  2. Search for "Windows PowerShell" or "PowerShell"
  3. Select the older version and click Uninstall

WARNING

Do not remove Windows PowerShell 5.1 completely as some system components and older scripts may depend on it.

Verification

Verify your configuration by:

  1. Opening Windows Terminal - it should start with PowerShell 7
  2. Right-clicking in File Explorer and selecting PowerShell - it should open PowerShell 7
  3. Checking the version in any PowerShell window: $PSVersionTable.PSVersion
powershell
# Check PowerShell version
$PSVersionTable.PSVersion

# Expected output for PowerShell 7:
# Major  Minor  Patch  PreReleaseLabel BuildLabel
# -----  -----  -----  --------------- ----------
# 7      3      4

Best Practices

  1. Keep Windows PowerShell 5.1: Some system administration tasks and older scripts require it
  2. Test scripts in both environments: Ensure compatibility before removing dependencies
  3. Use profile scripts: Customize your PowerShell 7 experience with $PROFILE
  4. Regular updates: Keep PowerShell 7 updated for security fixes and new features

By following these steps, you can successfully make PowerShell 7 your default shell while maintaining the ability to use Windows PowerShell when necessary for compatibility.