How to Install PowerShell on the Raspberry Pi?

Microsoft’s PowerShell offers Raspberry Pi users access to a powerful scripting environment for task automation. With PowerShell’s robust set of cmdlets and capabilities spanning Windows and Linux systems, Raspberry Pi becomes an even more versatile device for IT professionals and hobbyists.

How to Install PowerShell on the Raspberry Pi?

Installing the latest iteration of PowerShell on Raspberry Pi only takes a few quick steps. This guide will walk through the process to get you up and running with PowerShell on your Raspberry Pi device.

Prerequisites

Before installing PowerShell, ensure your Raspberry Pi environment meets these requirements:

  • Raspberry Pi OS Bullseye or later
  • ARMv7l or ARM64 architecture
  • .NET 6 Runtime or later
  • 20MB free disk space

Step 1 — Install .NET 6 Runtime

PowerShell 7 and later requires .NET 6 Runtime or newer.

Install the necessary package with this apt command:

sudo apt-get install -y libicu66

Next, enable the Microsoft package repository:

wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

Finally, install .NET Runtime with:

sudo apt-get update

sudo apt-get install -y aspnetcore-runtime-6.0

These commands add the required repositories, public key, and .NET environment needed for PowerShell.

Step 2 — Install PowerShell

With .NET available, installing PowerShell is straightforward:

 Download the ARM64 package  

wget https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell-lts_7.3.0-1.debian.11_arm64.deb

Install the package

sudo dpkg -i powershell-lts_7.3.0-1.debian.11_arm64.deb

Start PowerShell

pwsh

The PowerShell package works on ARMv7l and ARM64 architectures. This downloads the 64-bit ARM package, installs it, and launches the pwsh environment.

Upon launch, the output should show the PowerShell banner and version details:

PowerShell 7.3.0

https://aka.ms/powershell

Type ‘help’ to get help.

PS /

That’s it! PowerShell is now up and running on your Raspberry Pi device.

Using PowerShell on Raspberry Pi

With PowerShell installed, try out some basic commands to verify it is working properly:

 Get OS Details

Get-ComputerInfo

 List Disk Info

Get-Disk 

 Show Memory Use

Get-Process | Sort-Object VM -Descending | Select-Object VM,Name -First 5

These cmdlets retrieve system information, storage details, and current memory usage.

PowerShell also includes powerful scripting capabilities using .ps1 files. For example, to create a simple script:

 New script 

$ps1 = “test.ps1” 

 Add script logic

$content = @” 

Write-Output “My first PowerShell script on Raspberry Pi!”  

 Write output to script

$content | Out-File $ps1

 Run the script

test.ps1

This demonstrates the cmdlet-based syntax, here-string multi-line content, and script execution available within the pwsh environment.

With PowerShell working as expected, your Raspberry Pi now has access to thousands of cmdlets for scripting Windows, Linux, networking, cloud, and other administration tasks.

Key Takeaways

Installing PowerShell on Raspberry Pi takes just a few quick steps:

  • Ensure you have Raspberry Pi OS Bullseye or newer. ARM64 architecture requires 64-bit OS
  • Install .NET 6 Runtime from Microsoft package repository
  • Download and install Powershell package for ARM processor
  • Launch with pwsh and test basic cmdlets

PowerShell transforms Raspberry Pi into an incredibly versatile automation device – on par with any Windows or Linux workstation.

Conclusion

Getting PowerShell operational on Raspberry Pi requires .NET framework and the Linux arm package. By adding Microsoft repositories and installing the PowerShell deb file, users unlock access to cross-platform scripting and advanced Windows/Linux management right on Raspberry Pi.

With PowerShell fully functioning, explore cmdlets for system tasks, networking, clouds, containers, security, and more. PowerShell helps optimize Raspberry Pi capabilities and interoperability even further.

Frequently Asked Questions

  1. Is PowerShell 7 compatible with Raspberry Pi OS?
    Yes, PowerShell version 7 and later works on multiple Raspberry Pi OS iterations including Buster and Bullseye. It requires .NET 6 Runtime. 
  2. Can I install PowerShell on Raspberry Pi 3?
    Yes, PowerShell can be installed on any RPi model capable of running 64-bit or 32-bit Raspberry Pi OS Bullseye. 
  3. What Raspberry Pi OS do I need?
    Raspberry Pi OS Bullseye or newer. For 64-bit ARM devices, Bullseye ships with a 64-bit kernel by default. 
  4. How do I update Raspberry Pi OS to 64-bit?
    Use the rpi-update command if on an older OS, or download and install Bullseye 64-bit image. 
  5. Does PowerShell work on Raspberry Pi 400?
    Yes! The Raspberry Pi 400 can run PowerShell the same way as other Pi devices once RPi OS Bullseye 64-bit is installed. 
  6. Can I use PowerShell on Raspberry Pi Zero?
    Yes, PowerShell works on the Raspberry Pi Zero line. The Pi Zero and Pi Zero 2 are both 32-bit ARMv6, so use the ARMv7l PowerShell package. 
  7. How do I launch the PowerShell prompt on Raspberry Pi?
    Use the pwsh command after installing PowerShell. This loads the PowerShell 7+ interactive shell. 
  8. Why pwsh and not powershell?
    pwsh is the updated PowerShell Core executable, distinct from Windows PowerShell. So Linux and macOS use pwsh. 
  9. How can I run PowerShell scripts on Raspberry Pi?
    Save scripts as .ps1 files, ensure execute permissions, then launch with ./scriptname.ps1 from the PowerShell prompt. 
  10. Is there a PowerShell module repository for Raspberry Pi?
    Yes, the PowerShell Gallery contains Linux and ARM-compatible scripts and modules to further enhance capabilities. 
  11. Can I connect to Windows from PowerShell on Raspberry Pi?
    Yes, PowerShell offers robust remote management capabilities including PSRemoting for seamless Windows/Linux admin. 
  12. Is there an ISE or GUI for PowerShell on Raspberry Pi?
    Yes! Install the PowerShell ISE module, or explore Visual Studio Code with the PowerShell extension. 
  13. How do I remove or update PowerShell on Raspberry Pi?
    Use the standard apt-get remove and apt-get upgrade commands for the powershell-lts package. 
  14. Why does Install-Module fail on Raspberry Pi?
    PowerShell Gallery requires TLS 1.2+ which needs openssl 1.1.1 on Linux. Check with openssl version and update if too old. 
  15. Can I automate Windows tasks from Pi?
    Yes! Once configured for PSRemoting, RPi can remotely manage Exchange, Office 365, SQL Server, and more on Windows Servers. 
  16. Is there a Raspberry Pi PowerShell SDK?
    Yes, the PowerShell SDK contains ARM builds to compile custom modules and cmdlets optimized for Raspberry Pi. 
  17. What modules work best on Raspberry Pi?
    Useful modules include FileTransfer, SSHRemoting, DockerCompletion, and more from the PowerShell Gallery. The Pi-specific LernwerkstattModules offers additional functionality. 
  18. Can PowerShell access GPIO pins?
    Yes! The PiGpio module enables full GPIO pin access including voltage levels, PWM, interrupts, serial, and SPI communications over the GPIO interface. 
  19. Is PowerShell the best shell for Raspberry Pi?
    While Bash and Zsh remain popular, PowerShell offers greater versatility with easy Linux/Windows interoperability plus powerful automation capabilities. 
  20. What else can I do with PowerShell on Raspberry Pi?
    Manage file systems, access APIs, manipulate system resources, control GPIO devices, enable CI/CD workflows, and handle nearly any other task with easy scripting using cmdlets.

Leave a Comment