PowerShell
PowerShell is a cross-platform command line shell and scripting language.
Vendor: Microsoft
Developer: Microsoft
License: MIT
Web: https://docs.microsoft.com/en-us/powershell/
PowerShell is a cross-platform for Windows, Linux, and macOS available command line shell and scripting language from Microsoft.
Features
PowerShell is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. It can also be used to execute C# source code and call into .NET assemblies.
Additional features:
- consistent structure for the commands (Verb-Noun)
- consistent syntax
- completely object-based pipeline
- remoting
Installation
While PowerShell is not provided by any official openSUSE repositories, there are still a few easy ways to it on openSUSE Leap and Tumbleweed.
- Install directly from RPM
- Install binaries from tar.gz (tarball)
- Install using
sudo dotnet tool install --global powershell
command
This page will only cover the first two installation methods. The last one requires the installation of the dotnet
CLI and that is beyond the scope of this page.
From RPM Directly
The GitHub releases page does not provide a native openSUSE RPM, but it does have a RedHat RPM that works well enough on openSUSE Leap and Tumbleweed.
We will focus on the latest stable release of PowerShell. To install a different version of PowerShell, adjust the command to match the version you need. Versions can be found on PowerShell GitHub Releases page.
Download links for every package are found in the Assets section of the Release page. The Assets section may be collapsed, so you may need to click to expand it.
Install Dependencies
sudo zypper update && \ sudo zypper install libicu libopenssl3
Install PowerShell
sudo zypper install \ --allow-unsigned-rpm \ https://github.com/PowerShell/PowerShell/releases/download/v7.4.10/powershell-7.4.10-1.rh.x86_64.rpm
Common issues:
Problem: 1: nothing provides 'openssl-libs' needed by the to be installed powershell-7.4.10-1.rh.x86_64 Solution 1: do not install powershell-7.4.10-1.rh.x86_64 Solution 2: break powershell-7.4.10-1.rh.x86_64 by ignoring some of its dependencies
This is because RedHat's package name for openssl-libs is different than openSUSE's. PowerShell should still work if we ignore this dependency.
From Tarball
Install Dependencies
When installing PowerShell binaries using the Linux tar.gz
archive (aka tarball), but you need to set up the necessary dependencies first. These dependencies are the same as when installing from the RPM, with the addition of the curl
and tar
commands. These commands may already be installed on your system, but -generally speaking- it shouldn't hurt to still include them in your list of dependencies to install as show below.
sudo zypper update && \ sudo zypper install curl tar libicu libopenssl3
Download Tarball
You can check the version on PowerShell GitHub Releases. We will focus on the latest x64 LTS version, as we did with the RPM.
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.4.10/powershell-7.4.10-linux-x64.tar.gz -o /tmp/powershell.tar.gz
Make Installation Directory
sudo mkdir -p /opt/microsoft/powershell
Extract Tarball
sudo tar -xzf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/
Create Symlink to add pwsh
to PATH
sudo ln -s /opt/microsoft/powershell/pwsh /usr/bin/pwsh
Make pwsh
Executable
sudo chmod +x /usr/bin/pwsh
Validate Install
Regardless of your installation method, if PowerShell has been installed successfully, you should be able to run the code shown below to verify. You should see Hello Geekos! printed to your terminal in Green text (assuming your terminal supports colors).
pwsh -command Write-Host "Hello Geekos!" -ForegroundColor Green