Skip to content
Latchkey

How to Set the Default Shell to PowerShell or Bash on Windows in GitHub Actions

On windows-latest, run steps default to PowerShell Desktop; set shell explicitly to pick pwsh, bash, or cmd instead.

Set defaults.run.shell at the workflow or job level, or shell: on a single step. On Windows the choices include pwsh (PowerShell 7), powershell (Windows PowerShell 5.1), cmd, and bash (Git Bash).

Steps

  • Set runs-on: windows-latest on the job.
  • Add defaults: { run: { shell: pwsh } } to set the default for every run step.
  • Override a single step with shell: bash or shell: cmd where needed.

Workflow

.github/workflows/ci.yml
jobs:
  build:
    runs-on: windows-latest
    defaults:
      run:
        shell: pwsh
    steps:
      - uses: actions/checkout@v4
      - run: $PSVersionTable.PSVersion        # runs in PowerShell 7
      - run: echo "this step uses bash"
        shell: bash

Gotchas

  • pwsh is PowerShell 7 (cross-platform); powershell is the older Windows PowerShell 5.1.
  • Without shell:, Windows run steps default to powershell, which differs from pwsh in modules and behavior.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →