Install PowerShell in Visual Studio CodeSpaces

Sebastian Rogers
1 min readAug 25, 2023

TL;DR If you want PowerShell available in your GitHub Codespace just set up a devcontainer.json file with the “ghcr.io/devcontainers/features/powershell:1” feature

GitHub Codespaces are incredibly useful but if your working in PowerSHell its annoying to have to keep installing it, not hard see Install PowerShell on Linux — PowerShell | Microsoft Learn.

There is a much easier way by Using a predefined dev container configuration and then adding PowerShell as a feature. In this case we want the PowerShell (powershell) feature.

A good example can be found in the Simple-Innovation/simple-migration-api (github.com) project we maintain.

The key is the simple-migration-api/.devcontainer/devcontainer.json at main · Simple-Innovation/simple-migration-api (github.com) file.

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

The image is one of the predefined images and the feature installs PowerShell when the Codespace is instantiated.

As this project is about using PowerShell to do migrations it seems appropriate to have PowerShell installed when you spin it up.

TL;CR If you want PowerShell available in your GitHub CodeSpace just set up a devcontainer.json file with the “ghcr.io/devcontainers/features/powershell:1” feature

--

--

Sebastian Rogers

Technical Director for Simple Innovations Ltd. First paid for code in 1980, but still has all his own hair.