How to Install PowerShell on Debian 12 and 11

Install PowerShell on Debian 12 or 11 with APT. Covers LTS and preview packages, cmdlet examples, and complete removal steps.

Last updatedAuthorJoshua JamesRead time9 minGuide typeDebian

PowerShell on Debian gives administrators a cross-platform shell for automation work that already spans Linux, Windows, Azure, Microsoft 365, JSON APIs, and SSH-managed hosts. Before you install PowerShell on Debian, choose the right package path for the release, because Microsoft support and APT package availability differ between Debian 13 (Trixie), Debian 12 (Bookworm), and older Bullseye systems.

For supported stable installs, use the GitHub universal DEB package on Debian 13 and the Microsoft APT repository on Debian 12 systems that still need repository-managed updates. Microsoft lists Debian 13 and Debian 12 in its PowerShell support lifecycle, while Debian 11 is no longer listed in the supported Debian table.

Do not point a Debian 13 system at the Debian 12 Microsoft repository to force a stable package. Mixing Bookworm vendor packages into Trixie can create dependency and cleanup problems. Use the universal DEB package on Debian 13 unless Microsoft publishes a stable powershell candidate for Trixie in the repository you configure.

Install PowerShell on Debian

Choose the PowerShell Install Method for Debian

The useful decision is update ownership. The universal DEB package works well when the supported release has no stable APT package yet, while the Microsoft APT repository is easier to maintain when it publishes the package family for your Debian release.

Debian ReleaseRecommended MethodUpdate BehaviorUse This WhenBoundary
Debian 13 (Trixie)GitHub universal DEB packageRerun the download and checksum helper for a newer releaseYou need the supported stable PowerShell package on Debian 13The Trixie APT feed may expose only preview packages until Microsoft publishes a stable powershell candidate there
Debian 12 (Bookworm)Microsoft APT repositoryAPT-managed updates from packages.microsoft.comYou maintain an existing Bookworm host and want package-manager updatesMicrosoft lists Debian 12 support ending on 2026-06-10, so treat it as maintenance or upgrade-window coverage
Debian 11 (Bullseye)Upgrade path firstNot a current Microsoft-supported Debian targetYou are maintaining an older system and need a support decision before installingDebian LTS does not make Bullseye a Microsoft-supported PowerShell target

Microsoft’s official Debian install page documents a repository method and a manual package method. Keeping those paths separate prevents a Trixie host from receiving a Bookworm source file just to satisfy an APT search for powershell.

Prepare Debian for PowerShell Installation

Refresh APT metadata before installing helper packages. If your account cannot use sudo, set up admin access first with the Debian sudoers guide.

sudo apt update

Install the tools used by the supported methods. ca-certificates lets APT and curl verify HTTPS endpoints, curl downloads repository and release files, gpg converts Microsoft’s APT signing key for the Debian 12 repository path, and jq parses the GitHub release metadata used by the Debian 13 package helper.

sudo apt install ca-certificates curl gpg jq -y

The -y option accepts the APT prompt automatically. Remove it if you prefer to review the transaction before confirming. The GitHub helper also uses curl -fL and curl -fsSL; the curl command guide explains those flags in more detail.

Check Debian Release and Architecture

Use Debian’s /etc/os-release file for release detection. Minimal Debian images often omit lsb_release, so this check avoids an unnecessary prerequisite just to learn the version number.

. /etc/os-release
printf 'Debian %s (%s)\n' "$VERSION_ID" "$VERSION_CODENAME"
dpkg --print-architecture

Example output from a Trixie amd64 host looks like this:

Debian 13 (trixie)
amd64

PowerShell’s Debian repository package and the universal Debian package in this workflow target amd64. Do not assume an ARM or i386 machine can use the same package name or release asset.

Install PowerShell on Debian 13 with the Universal DEB Package

Debian 13 is supported by Microsoft, but the practical stable install path is the universal DEB package from the official PowerShell GitHub releases when APT does not show a stable powershell candidate for Trixie. The helper resolves the latest non-preview release, downloads the matching amd64 DEB package, converts the official UTF-16 checksum file to UTF-8, verifies the package, and installs it with APT so Debian can resolve dependencies.

(
  set -euo pipefail

  release_json=$(curl -fsSL https://api.github.com/repos/PowerShell/PowerShell/releases/latest)
  package_url=$(printf '%s' "$release_json" | jq -r 'first(.assets[] | select(.name | test("^powershell_[0-9.]+-1\\.deb_amd64\\.deb$")) | .browser_download_url) // empty')
  checksums_url=$(printf '%s' "$release_json" | jq -r 'first(.assets[] | select(.name == "hashes.sha256") | .browser_download_url) // empty')

  if [ -z "$package_url" ] || [ "$package_url" = "null" ] || [ -z "$checksums_url" ] || [ "$checksums_url" = "null" ]; then
    printf '%s\n' 'PowerShell release assets were not found.'
    exit 1
  fi

  package_file="/tmp/${package_url##*/}"
  checksums_file="/tmp/hashes.sha256"
  trap 'rm -f "$package_file" "$checksums_file"' EXIT

  curl -fL -o "$package_file" "$package_url"
  curl -fsSL -o "$checksums_file" "$checksums_url"

  (
    cd /tmp
    iconv -f UTF-16LE -t UTF-8 "$checksums_file" | grep -F " *${package_file##*/}" | sha256sum -c -
  )

  sudo apt install "$package_file"
)

The parenthesized block runs in a subshell, so the guarded exit 1 stops the helper without closing your interactive terminal. The checksum conversion matters because the current hashes.sha256 release asset is UTF-16 text; feeding it directly to sha256sum -c can fail even when the file is valid.

Confirm the package name, version, architecture, and command after installation:

dpkg-query -W -f='${binary:Package} ${Version} ${Architecture}\n' powershell
command -v pwsh
pwsh --version

Example stable-package output has this shape. The version changes as Microsoft publishes new releases.

powershell 7.6.1-1.deb amd64
/usr/bin/pwsh
PowerShell 7.6.1

Install PowerShell on Debian 12 with the Microsoft APT Repository

Use the repository method on Debian 12 when you want APT to track PowerShell updates through packages.microsoft.com. The setup block deliberately stops on any release other than Bookworm because the repository source is release-specific and should not be copied onto Debian 13 or Debian 11.

(
  set -euo pipefail

  . /etc/os-release

  if [ "$VERSION_ID" != "12" ]; then
    printf 'This repository method is for Debian 12 (Bookworm), not Debian %s (%s).\n' "$VERSION_ID" "$VERSION_CODENAME"
    exit 1
  fi

  if [ "$(dpkg --print-architecture)" != "amd64" ]; then
    printf '%s\n' 'The Microsoft PowerShell repository package in this workflow is for amd64 systems.'
    exit 1
  fi

  keyring="/usr/share/keyrings/microsoft-powershell.gpg"
  source_file="/etc/apt/sources.list.d/microsoft-powershell.sources"

  curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --yes -o "$keyring"

  printf '%s\n' \
    'Types: deb' \
    "URIs: https://packages.microsoft.com/debian/$VERSION_ID/prod" \
    "Suites: $VERSION_CODENAME" \
    'Components: main' \
    'Architectures: amd64' \
    "Signed-By: $keyring" | sudo tee "$source_file" >/dev/null
)

The source file uses Debian’s DEB822 format and pins the Microsoft signing key to this repository through Signed-By. Inspect the saved keyring before refreshing APT:

gpg --show-keys --with-fingerprint /usr/share/keyrings/microsoft-powershell.gpg

The Microsoft release key should show this fingerprint:

BC52 8686 B50D 79E3 39D3  721C EB3E 94AD BE12 29CF

Refresh package metadata and check that the repository actually provides powershell before installing it:

sudo apt update
apt-cache policy powershell

Relevant output should show a Bookworm candidate from Microsoft’s repository:

powershell:
  Installed: (none)
  Candidate: 7.6.1-1.deb
  Version table:
     7.6.1-1.deb 500
        500 https://packages.microsoft.com/debian/12/prod bookworm/main amd64 Packages

Install PowerShell after the candidate appears:

sudo apt install powershell

Verify the package and command path:

dpkg-query -W -f='${binary:Package} ${Version} ${Architecture}\n' powershell
command -v pwsh
pwsh --version
powershell 7.6.1-1.deb amd64
/usr/bin/pwsh
PowerShell 7.6.1

Understand PowerShell Package Variants on Debian

Microsoft publishes more than one PowerShell package name in some Debian feeds. Check the candidate before changing package names, because the name that sounds newest may not be the branch you expect.

apt-cache policy powershell powershell-lts powershell-preview
PackageCommandRoleDebian Notes
powershellpwshNormal release packageRecommended for most installs. On Debian 12, this package can provide the newer 7.6 LTS branch through the Microsoft APT repository.
powershell-ltspwshOlder LTS package family in the repositoryOn Debian 12, the candidate can remain on the older 7.4 LTS branch while powershell provides the newer 7.6 LTS branch. Check the candidate and lifecycle before using it.
powershell-previewpwsh-previewPreview buildsPreview is for testing upcoming releases and can be installed side-by-side with stable PowerShell. Do not use it for production automation.

If you intentionally choose powershell-lts or powershell-preview from a repository that provides it, carry that exact package name through update and removal. For preview sessions, start the shell with pwsh-preview instead of pwsh.

On Debian 12, install only the branch you actually want. The LTS package can trail the normal powershell package when a newer LTS branch has already reached the main package name:

sudo apt install powershell-lts

Use the preview package only for testing upcoming PowerShell behavior:

sudo apt install powershell-preview

Verify the package and command name after installing an alternate branch:

dpkg-query -W -f='${binary:Package} ${Version}\n' powershell-lts powershell-preview 2>/dev/null || true
command -v pwsh || true
command -v pwsh-preview || true

Start and Use PowerShell on Debian

Start an Interactive PowerShell Session

Start the normal PowerShell package from a terminal:

pwsh

The prompt changes to a PS prompt. Type exit to return to Bash, Zsh, or whichever shell launched PowerShell.

exit

If you installed the preview package intentionally, start that side-by-side build with pwsh-preview.

Check Runtime Details Inside PowerShell

Inside a PowerShell session, inspect the active PowerShell version, install home, and .NET runtime:

$PSVersionTable.PSVersion
$PSHOME
[System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription

A stable Debian package normally uses /opt/microsoft/powershell/7 as $PSHOME. Preview builds use a separate /opt/microsoft/powershell/7-preview path.

Use Linux Paths with PowerShell Cmdlets

PowerShell understands normal Linux paths, but scripts are clearer when they use full cmdlet names instead of aliases such as ls or cat. List a few entries from /etc with selected properties:

Get-ChildItem /etc | Select-Object -First 5 Name, Mode

Read Debian’s release file and return the matching line as plain text:

Get-Content /etc/os-release | Select-String PRETTY_NAME | ForEach-Object Line

Sort running processes by CPU time and show only the fields that matter for a quick terminal review:

Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 ProcessName, Id, CPU

PowerShell’s object pipeline becomes more useful when data is already structured. This local JSON example converts text into an object and selects named properties without manual text parsing:

'{"name":"debian","release":13}' | ConvertFrom-Json | Select-Object name, release

Read Help and Update Local Help Files

PowerShell includes command discovery and help lookup. Start with Get-Command when you know part of a command name:

Get-Command -Name *Process*

Read full help for a cmdlet:

Get-Help Get-Process -Full

If help content is missing, download it for your user account instead of writing into system directories:

Update-Help -Scope CurrentUser

Know Where PowerShell Stores Profiles, Modules, and History

PowerShell follows Linux user-directory conventions for user data. These paths matter when you create profiles, install modules, back up shell state, or remove PowerShell completely.

  • User profile for the normal console host: ~/.config/powershell/Microsoft.PowerShell_profile.ps1
  • User modules: ~/.local/share/powershell/Modules
  • PSReadLine history: ~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
  • Shared modules for all users: /usr/local/share/powershell/Modules

For remote administration, PowerShell remoting on Linux uses SSH transport. Install and enable OpenSSH first with the Debian SSH setup guide before building a remoting workflow around Debian hosts.

Update PowerShell on Debian

Update a Universal DEB Install

The universal DEB package is not tied to an APT repository, so normal apt upgrade does not discover new PowerShell releases by itself. Rerun the Debian 13 GitHub helper when you want to update this method. It resolves the latest non-preview release, verifies the checksum, and installs the newer package over the existing one.

Check the current installed version before and after the update:

pwsh --version
dpkg-query -W -f='${binary:Package} ${Version}\n' powershell

Update a Debian 12 Repository Install

For the Debian 12 repository method, refresh APT and upgrade only the installed PowerShell package:

sudo apt update
sudo apt install --only-upgrade powershell

The --only-upgrade option prevents APT from installing PowerShell if it is not already present. If you deliberately installed powershell-lts or powershell-preview from the repository, replace the package name with that exact installed package.

Remove PowerShell from Debian

Remove the PowerShell Package

Remove the normal PowerShell package with APT. This applies to both the universal DEB install and the Debian 12 repository install because both register the package as powershell.

sudo apt remove powershell

Clear Bash’s command cache and verify that pwsh is no longer on PATH:

hash -r
if command -v pwsh >/dev/null 2>&1; then
  command -v pwsh
else
  printf '%s\n' 'pwsh is no longer on PATH'
fi

If you installed the preview package, remove powershell-preview and check pwsh-preview instead.

Remove the Debian 12 Microsoft Repository

Only remove the repository source when you used the Debian 12 repository method. Direct universal DEB installs do not create an APT source file.

sudo rm -f /etc/apt/sources.list.d/microsoft-powershell.sources

source_refs=0
for source_path in /etc/apt/sources.list /etc/apt/sources.list.d; do
  if [ -e "$source_path" ] && grep -Rqs 'microsoft-powershell.gpg' "$source_path"; then
    source_refs=1
    break
  fi
done

if [ "$source_refs" -eq 1 ]; then
  printf '%s\n' 'Another APT source still references /usr/share/keyrings/microsoft-powershell.gpg'
else
  sudo rm -f /usr/share/keyrings/microsoft-powershell.gpg
fi

sudo apt update
apt-cache policy powershell

When no remaining source provides PowerShell, the key signal is Candidate: (none). A local /var/lib/dpkg/status entry can still appear after apt remove; that is residual package history, not an active repository source.

powershell:
  Installed: (none)
  Candidate: (none)

For a broader review of external source files on a Debian system, use the workflow to manage third-party APT repositories on Debian.

Remove PowerShell User Data

Package removal leaves user profiles, module caches, and command history in your home directory. Inspect the paths before deleting them:

for path in ~/.config/powershell ~/.local/share/powershell ~/.cache/powershell; do
  [ -e "$path" ] && printf '%s\n' "$path"
done

The next command permanently deletes PowerShell profiles, command history, downloaded help, and user-installed modules for the current account. Back up scripts or modules you want to keep before deleting these directories.

rm -rf ~/.config/powershell ~/.local/share/powershell ~/.cache/powershell

Troubleshoot PowerShell on Debian

APT Cannot Locate powershell on Debian 13

E: Unable to locate package powershell means APT has no stable powershell package in the enabled sources. On Debian 13, this can happen even when the Microsoft Trixie feed exists, because package families can appear at different times.

apt-cache policy powershell powershell-preview

If powershell has no candidate but powershell-preview does, do not install preview as a substitute for a stable automation shell. Use the universal DEB package for stable PowerShell on Debian 13, or wait until the repository publishes the stable package for Trixie.

PowerShell Release Assets Were Not Found

The GitHub helper depends on jq and the GitHub releases API. Confirm that jq is installed and that the API returns a release tag:

jq --version
curl -fsSL https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq -r '.tag_name'

If the API request fails, check network access, proxy settings, DNS, or a temporary GitHub rate-limit condition. Retry after the API returns a release tag such as v7.6.1.

sha256sum Reports No Properly Formatted Checksum Lines

The official hashes.sha256 file can be UTF-16 text. Convert it before passing the matching line to sha256sum -c:

iconv -f UTF-16LE -t UTF-8 /tmp/hashes.sha256 | grep -F ' *powershell_7.6.1-1.deb_amd64.deb' | sha256sum -c -

Replace the filename with the package file you downloaded. The GitHub helper handles this dynamically so the filename stays aligned with the resolved release.

NO_PUBKEY or Repository Signature Errors

A missing key error during sudo apt update usually means the Debian 12 repository source exists but the keyring path in Signed-By is missing or invalid. Inspect the saved keyring first:

gpg --show-keys --with-fingerprint /usr/share/keyrings/microsoft-powershell.gpg

The Microsoft release key should show this fingerprint:

BC52 8686 B50D 79E3 39D3  721C EB3E 94AD BE12 29CF

If the file is missing, recreate the keyring and refresh APT:

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/microsoft-powershell.gpg
sudo apt update

The Wrong PowerShell Command Starts

Stable and repository LTS packages use pwsh. Preview packages use pwsh-preview. Check which command is active and which package owns it:

command -v pwsh || true
command -v pwsh-preview || true
dpkg -S "$(command -v pwsh)" 2>/dev/null || true

If both stable and preview are installed, use the command that matches the branch you intend to run. Avoid mixing preview into production scripts unless you are explicitly testing upcoming PowerShell behavior.

Debian 11 Needs a Support Decision First

Debian 11 remains under Debian LTS, but Microsoft’s PowerShell Debian support list no longer includes Bullseye. Do not add a Bookworm or Trixie Microsoft source to a Bullseye host. Upgrade the system first, or keep PowerShell off that host unless your organization accepts an unsupported install path and owns the maintenance risk.

Conclusion

PowerShell is installed on Debian with a method that matches the release: a checksum-verified universal DEB package for Debian 13, or an APT-managed Microsoft repository path for Debian 12. From here, build scripts around full cmdlet names, verify the active pwsh path, and set up SSH first when Debian hosts need remote PowerShell management.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: