How to Install PowerShell on CentOS 8

Install PowerShell on CentOS 8

In this article, we will have explained the necessary steps to install and configure PowerShell on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Microsoft PowerShell is a .net-based configuration management and automation tool initially developed by Microsoft for the Windows operating system. These features are not available on the traditional Linux shell. It consists of a cross-platform (Windows, Linux, and macOS) command-line shell and associated scripting language.

Install PowerShell on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf update

Step 3. Install PowerShell on CentOS.

The PowerShell RPM package is not available on your default CentOS repositories. We’ll add official Microsoft repositories using the command:

curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

Next, install Microsoft PowerShell classic version you should execute the following command:

sudo dnf install powershell

After the installation, start PowerShell using the command:

[root@linuxtips.us ~]$ rpm -qi powershell
Name : powershell
Version : 6.2.4
Release : 1.rhel.7
Architecture: x86_64
Install Date: Fri 11 Mar 2020 01:49:13 PM PKT
Group : shells
Size : 156967268
License : MIT License
Signature : RSA/SHA256, Wed 16 Dec 2019 08:46:07 AM PKT, Key ID eb3e94adbmw9cf
Source RPM : powershell-6.2.3-1.rhel.7.src.rpm
Build Date : Wed 16 Dec 2019 03:11:50 AM PKT
Build Host : e7bbmw9b4a
Relocations : /
Packager : PowerShell Team PowerShellTeam@hotmail.com
Vendor : Microsoft Corporation
URL : https://microsoft.com/powershell
Summary : PowerShell is an automation and configuration management platform.
Description :
PowerShell is an automation and configuration management platform.
It consists of a cross-platform command-line shell and associated scripting language.

Then, try to run few commands to verify your installation:

PS /home/root> pwd
Path
/home/sabi
PS /home/root> mkdir /tmp/test
PS /home/root> cd /tmp/test
PS /tmp/root> pwd
Path
/tmp/test
PS /tmp/test> get-process | more
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
0 0.00 0.04 0.00 1213 …85 (sd-pam)
0 0.00 0.04 0.00 2540 …32 (sd-pam)
0 0.00 0.96 0.15 974 974 accounts-daemon
0 0.00 0.00 0.00 122 0 acpi_thermal_pm
0 0.00 0.41 0.00 854 853 alsactl
0 0.00 0.97 0.02 1993 …94 at-spi-bus-laun
0 0.00 0.96 0.01 2672 …76 at-spi-bus-laun
0 0.00 0.00 0.01 2001 …96 at-spi2-registr
0 0.00 0.44 0.03 2680 …76 at-spi2-registr
0 0.00 0.00 0.00 477 0 ata_sff
0 0.00 0.41 0.01 1087 …77 atd
0 0.00 0.30 0.06 818 815 auditd
0 0.00 0.75 0.11 858 850 avahi-daemon
0 0.00 0.03 0.00 958 850 avahi-daemon
0 0.00 3.57 0.06 4186 …96 bash
0 0.00 1.38 0.03 2085 …45 boltd
0 0.00 0.29 0.06 878 873 chronyd
0 0.00 0.97 0.13 2185 …45 colord
0 0.00 0.00 0.00 19 0 cpuhp/0
0 0.00 0.48 0.20 1991 …91 crond
0 0.00 0.00 0.00 27 0 crypto
0 0.00 0.79 0.05 1963 …63 cupsd
0 0.00 3.22 1.81 875 855 dbus-daemon
0 0.00 0.88 0.20 1902 …02 dbus-daemon
--More--

That’s all you need to do to install PowerShell on CentOS 8. I hope you find this quick tip helpful. For further reading on PowerShell, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.