Running PowerShell Core on Raspberry Pi 2


While enjoying some days off during Christmas and New Year I found some time to install PowerShell Core on my Raspberry Pi 2.

Pre-requisites:

  • Raspberry Pi version 2 or higher
  • Windows 10 with Windows Subsystem for Linux enabled
  • The following tools:
    • Windows Subsystem for Linux (Ubuntu)
    • Chocolatey (Package Manager for Windows)
    • Putty
    • WinSCP
    • Etcher

Here are the steps to get it working.

Step 1. Setup your Pi

Download Raspbian and follow the installation instructions to get it onto your Pi.
Once your Pi is up and running, enable SSH remoting.

I downloaded the Raspbian Stretch with Desktop version. This can take some time to download. Please be patient 😃 and get a cup of coffee or tea while the image is being downloaded.

Next download Etcher (graphical SD card writing tool) and install it.

The easiest way is using Chocolatey, which is a Windows Package Manager and install it with:

choco install Etcher

And while you are installing Etcher it's also a good idea to install Putty and WinSCP too, using Chocolatey.

choco install putty
choco install winscp

Open Etcher and select downloaded Raspbian Image and select correct USB drive and click on Flash.

Wait for the flash to complete.

Insert your micro-SD into your Raspberry Pi and make sure you can connect to it. You need to enable SSH as a first step.
It can be enabled manually from the desktop:

  1. Launch Raspberry Pi Configuration from the Preferences menu
  2. Navigate to the Interfaces tab
  3. Select Enabled next to SSH
  4. Click OK

Pro tip: Use Fing tool to scan your network to find the IP Address of your Raspberry Pi.

Open Windows Subsystem for Linux (WSL) and SSH into your raspberry pi.

Change you pi password. Enter:

passwd

Step 2. Install Powerhell Core on Raspberry Pi

Connect to your Raspberry Pi with Putty or WSL and run the following commands:

# Install prerequisites
sudo apt-get install libunwind8

# Grab the latest tar.gz
wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-rc.2/powershell-6.0.0-rc.2-linux-arm32.tar.gz

# Make folder to put powershell
mkdir ~/powershell

# Unpack the tar.gz file
tar -xvf ./powershell-6.0.0-rc.2-linux-arm32.tar.gz -C ~/powershell

Start PowerShell

~/powershell/pwsh

If everything worked out correctly you see the following.

What's next?

You could start installing the PowerShell UniversalDashboard module from Adam Driscoll.

Run:

install-module universaldashboard -scope currentuser

You can now use WinSCP to copy files from your local machine to the remote RaspberryPi. You can download some example Dashboards here: https://github.com/adamdriscoll/poshprotools/tree/master/examples/universal-dashboard

Now go back to your RaspberryPi SSH connection and run:

Start-UDDashboard -Content { & '/home/pi/New-UDWeatherDashboard.ps1' -State 'Noord-Holland' -City 'Halfweg'} -Port 9292

Open now http://(raspberrypi ipaddress):9292 and you should see something like this.

Have fun running PowerShell Core on your Raspberry Pi!

References:

Comments (3)

  1. Maikel van Gorkom says:

    Thanks, was really searching on how to run PS on a raspberry. Pi 1 isn’t supported? What’s the main difference you can run PS on a Pi2 and not on a Pi1?

    1. Hi Maikel,

      The CoreCLR (and thus PowerShell Core) will only work on Pi 2 and Pi 3 devices as other devices like Pi Zero have an unsupported processor.

      Regards,
      Stefan Stranger

  2. Don isenstadt says:

    It installed but the weather script does not work..looks like it does not recognize operators in script.
    Getting ‘<‘ operator reserved for future use among other errors.
    The $PSVersionTable returns the same values as your sexample

Skip to main content