PowerShell

Jump to: navigation, search
PowerShell
PowerShell icon/logo

PowerShell is a cross-platform command line shell and scripting language.

Download for openSUSE

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.

  1. Install directly from RPM
  2. Install binaries from tar.gz (tarball)
  3. 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.

Install Dependencies

sudo zypper update && \
  sudo zypper install libicu60_2 libopenssl1_0_0

Install PowerShell

sudo zypper install \
  --allow-unsigned-rpm \
  https://github.com/PowerShell/PowerShell/releases/download/v7.2.3/powershell-lts-7.2.3-1.rh.x86_64.rpm


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 libicu60_2 libopenssl1_0_0

Download Tarball

curl -L https://github.com/PowerShell/PowerShell/releases/download/v6.1.3/powershell-6.1.3-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

External links