How to enable PowerShell in Github Codespaces?

2 minute read

Are you the one stuck with the below issue?

  1. Unable to find the PowerShell in the GitHub codespaces terminal.
  2. PowerShell is not available after installing the extension in the GitHub codespaces.
  3. Not comfortable with Bash.

See the below image, the PowerShell option is missing in the CodeSpaces terminal and you're going to learn how to enable it now.

  Github CodeSpaces - PowerShell missing

Fig 1. Github CodeSpaces - PowerShell missing

No worries. You can enable the PowerShell in the GitHub codespaces because many of us have done it already.

1. Go to your GitHub repository

  Github repository - dev container
Fig 2. Github repository - dev container

2. Open the “devcontainer.json”

Open the file "devcontainer.json".
If you haven't configured the dev container already then configure the new one by selecting the "configure dev container" option under the CodeSpaces. Refer to the below image,

  GitHub CodeSpaces - Add dev container

Fig 3. Github CodeSpaces - Add dev container

3. Launch your codespace

4. Add PowerShell to the dev container

Go to the devcontainer folder -> devcontainer.json and add the below lines to enable the PowerShell inside your container.

{
  "image": "mcr.microsoft.com/devcontainers/universal:2",
  "features": {
    "ghcr.io/devcontainers/features/powershell:1": {}
  }
}

Rebuild the container,

  Github CodeSpaces - Add PowerShell and rebuild the container

Fig 4. Github CodeSpaces - Add PowerShell and rebuild the container

Here you go, the PowerShell is enabled in your GitHub CodeSpaces terminal.

  Github CodeSpaces - PowerShell enabled

Fig 5. Github CodeSpaces - PowerShell enabled

Leave a comment