DebianDebian Based

How To Install PowerShell on Debian 13

Install PowerShell on Debian 13

PowerShell has evolved far beyond its Windows origins. What began as a Windows-exclusive automation framework has transformed into a robust, cross-platform scripting environment that Linux administrators are increasingly embracing. For Debian 13 users seeking powerful automation capabilities and consistent scripting across multiple operating systems, PowerShell offers an excellent solution that bridges the gap between Windows and Linux environments.

This comprehensive guide walks you through installing PowerShell on Debian 13 (Trixie), covering multiple installation methods, troubleshooting common issues, and configuring your environment for optimal performance. Whether you’re a system administrator managing hybrid infrastructures or a developer building cross-platform tools, this tutorial provides everything you need to get PowerShell running smoothly on your Debian system.

Understanding PowerShell on Linux Systems

PowerShell Core represents Microsoft’s commitment to open-source development and cross-platform compatibility. Unlike the original Windows PowerShell built on the .NET Framework, PowerShell Core runs on .NET Core, enabling it to function seamlessly across Windows, macOS, and Linux distributions.

The benefits are compelling. PowerShell delivers an object-oriented pipeline that processes structured data rather than plain text, making complex data manipulation remarkably straightforward. Its extensive cmdlet library provides consistent syntax across different platforms, and the scripting language itself offers powerful automation capabilities that rival traditional shell scripting while maintaining better readability.

For Debian users, PowerShell integration means you can leverage both native Linux tools and PowerShell cmdlets within the same workflow. This flexibility proves invaluable when managing mixed environments or developing automation scripts that need to run across different operating systems.

System Requirements and Prerequisites

Before diving into installation, verify your system meets the necessary requirements. PowerShell on Debian 13 requires a 64-bit processor supporting x64 or ARM64 architecture. You’ll need at least 1 GB of RAM, though 2 GB is recommended for comfortable operation. The installation itself consumes approximately 150 MB of disk space.

Your Debian 13 system should be relatively up-to-date. Root or sudo access is essential for installation. An active internet connection enables package downloads, and you’ll need the wget utility, which we’ll install if it’s not already present.

Important consideration for Debian 13 users: Some PowerShell versions may encounter dependency conflicts with the libicu76 library in Debian 13. This compatibility issue primarily affects certain 7.5.x versions. We’ll address workarounds later in this guide.

Preparing Your Debian System

Start by updating your package repositories and installed software. Open a terminal and execute:

sudo apt-get update && sudo apt-get upgrade

This ensures your system has the latest security patches and package information. The update process may take several minutes depending on how current your system is.

Verify you’re running Debian 13 by checking the version information:

source /etc/os-release
echo $VERSION_ID

You should see “13” or “trixie” in the output.

Install wget if it’s not already available:

sudo apt-get install -y wget

This download utility will fetch necessary packages during installation.

Method 1: Installing via Microsoft Repository

The Microsoft repository method offers the most maintainable approach. This installation path enables automatic updates through Debian’s standard package management system, ensuring you receive security patches and feature updates alongside your other system packages.

Step 1: Download Microsoft’s Repository Configuration

First, obtain the repository GPG keys and configuration package:

wget -q https://packages.microsoft.com/config/debian/13/packages-microsoft-prod.deb

This command downloads the repository configuration for Debian 13 specifically. The -q flag keeps the output quiet, reducing terminal clutter.

Step 2: Register the Microsoft Repository

Install the downloaded configuration package:

sudo dpkg -i packages-microsoft-prod.deb

The dpkg command installs the .deb package, which adds Microsoft’s repository to your system’s software sources. This enables apt to locate PowerShell packages.

Step 3: Clean Up Downloaded Files

Remove the configuration package you no longer need:

rm packages-microsoft-prod.deb

This keeps your download directory tidy and frees minimal disk space.

Step 4: Refresh Package Information

Update your package lists to include the newly added repository:

sudo apt-get update

This step is crucial. Your system now knows about PowerShell packages available from Microsoft’s repository.

Step 5: Install PowerShell

Execute the installation command:

sudo apt-get install -y powershell

The package manager downloads PowerShell and installs all required dependencies automatically. Installation typically completes within a few minutes, depending on your internet connection speed. You’ll see progress indicators as packages download and configure.

Step 6: Verify the Installation

Confirm PowerShell installed correctly by launching it:

pwsh

You should see the PowerShell prompt appear, displaying version information. Type exit to return to your regular shell.

Method 2: Installing from Binary Package

Binary package installation provides an alternative when you need offline installation capabilities, require a specific PowerShell version, or work in air-gapped environments without internet access.

Downloading the Correct Package

Visit PowerShell’s GitHub releases page to find the appropriate binary. For most Debian 13 systems, you’ll want the amd64 package. Download it using wget:

wget https://github.com/PowerShell/PowerShell/releases/download/v7.5.2/powershell_7.5.2-1.deb_amd64.deb

Replace the version number with your desired release. ARM-based systems need the arm64 or armhf package instead.

Installing the Binary Package

Install the downloaded package:

sudo dpkg -i powershell_7.5.2-1.deb_amd64.deb

If dpkg reports missing dependencies, resolve them with:

sudo apt-get install -f

This command instructs apt to fix broken dependencies automatically. It downloads and installs any missing libraries PowerShell requires.

Cleanup

Remove the installer package:

rm powershell_7.5.2-1.deb_amd64.deb

Launching and Testing PowerShell

Start PowerShell by typing:

pwsh

The PowerShell prompt differs from your regular Bash prompt. You’ll see something like PS /home/username> indicating you’re in a PowerShell session.

Check your installation details by running:

$PSVersionTable

This displays comprehensive version information including the PowerShell version, .NET runtime version, operating system details, and platform architecture. It’s useful for troubleshooting and confirming you’re running the expected version.

Test basic functionality with simple cmdlets:

Get-Date
Get-Process

These commands display the current date/time and running processes respectively, confirming PowerShell works correctly.

Post-Installation Configuration

PowerShell on Linux uses specific directories for profiles and modules. Your user-specific profile lives at ~/.config/powershell/Microsoft.PowerShell_profile.ps1. This script runs automatically whenever you start PowerShell.

Create a basic profile:

mkdir -p ~/.config/powershell
nano ~/.config/powershell/Microsoft.PowerShell_profile.ps1

Add customizations like aliases or functions. For example:

# Set custom prompt
function prompt {
    "PS [$env:USER@$env:HOSTNAME] > "
}

# Common aliases
Set-Alias -Name ll -Value Get-ChildItem

Save the file and restart PowerShell to see your changes take effect.

PowerShell modules install to ~/.local/share/powershell/Modules by default. The PowerShell Gallery (PSGallery) provides thousands of community modules. Install modules using:

Install-Module -Name ModuleName -Scope CurrentUser

Updating PowerShell

Repository installations update through standard apt commands:

sudo apt-get update
sudo apt-get upgrade powershell

This keeps PowerShell current alongside your other system packages.

Binary installations require manual updates. Download the newer version and install it following the same binary installation process. The new version replaces the old one automatically.

Check your current PowerShell version anytime:

pwsh --version

Troubleshooting Common Issues

Debian 13 Dependency Problems

Debian 13’s libicu76 library can conflict with certain PowerShell versions. If you encounter “unmet dependencies” errors specifically mentioning libicu, try these solutions:

Install an earlier PowerShell version known to work with Debian 13. PowerShell 7.4.x versions typically have better compatibility. Download the specific version from GitHub releases.

Alternatively, wait for updated PowerShell packages that explicitly support Debian 13’s library versions. The PowerShell team actively addresses distribution-specific issues.

Repository Authentication Failures

If GPG key verification fails during installation:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

This manually imports Microsoft’s signing key.

Missing Dependencies

The error “dpkg: dependency problems” indicates missing libraries. Always run:

sudo apt-get install -f

This command resolves dependency chains automatically, downloading whatever PowerShell needs.

Runtime Errors

Segmentation faults or crashes often stem from corrupted installations. Completely remove PowerShell:

sudo apt-get purge powershell
sudo apt-get autoremove

Then reinstall using your preferred method.

Module Installation Issues

If Install-Module fails with certificate errors, update your certificate store:

sudo apt-get install ca-certificates
sudo update-ca-certificates

For proxy environments, configure PowerShell’s web requests:

$PSDefaultParameterValues['*:Proxy'] = 'http://proxy.example.com:8080'

Uninstalling PowerShell

Remove repository-installed PowerShell:

sudo apt-get remove powershell

For complete removal including configuration files:

sudo apt-get purge powershell
sudo apt-get autoremove

Remove the Microsoft repository if you no longer need it:

sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update

Delete user profile and module directories:

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

Congratulations! You have successfully installed PowerShell. Thanks for using this tutorial for installing the latest version of PowerShell on Debian 13 “Trixie” system. For additional help or useful information, we recommend you check the official Microsoft website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button