10 C
Texas

How To Install PowerShell on CentOS 8 / RHEL 8

PowerShell is a scripting language basically written for Windows Operating Systems but also it supports Linux/Unix systems. For users who were using Windows and new to Linux, can also install PowerShell. PowerShell is well known Object Oriented Scripting language.In this tutorial, you will cover the installation of PowerShell on your Linux system like CentOS 8 / RHEL 8. Just follow the below steps to easily Install PowerShell on CentOS / RHEL 8.

Step 1: Adding PowerShell Repository

As PowerShell is not available on CentOS 7 / 8 operating system, we have to add it from Microsoft repositories by running

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

Now, move towards the installation of PowerShell

Step 2: Installing PowerShell on CentOS 7 / 8

- Advertisement -

Fire the given command to get install PowerShell on RHEL / CentOS 7 / 8.

[sabi@localhost ~]$ sudo yum -y install powershell
packages-microsoft-com-prod 297 kB/s | 3.9 MB 00:13
Last metadata expiration check: 0:00:09 ago on Fri 27 Dec 2019 01:48:08 PM PKT.
Dependencies resolved.
Package Arch Version Repository Size
Installing:
powershell x86_64 6.2.3-1.rhel.7 packages-microsoft-com-prod 54 M
Transaction Summary
Install 1 Package
Total download size: 54 M
Installed size: 54 M
Downloading Packages:
powershell-6.2.3-1.rhel.7.x86_64.rpm 1.1 MB/s | 54 MB 00:47
Total 1.1 MB/s | 54 MB 00:47
warning: /var/cache/dnf/packages-microsoft-com-prod-687ce8c973efa9d3/packages/powershell-6.2.3-1.rhel.7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
packages-microsoft-com-prod 358 B/s | 983 B 00:02
Importing GPG key 0xBE1229CF:
Userid : "Microsoft (Release signing) [email protected]"
Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
From : https://packages.microsoft.com/keys/microsoft.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : powershell-6.2.3-1.rhel.7.x86_64 1/1
Running scriptlet: powershell-6.2.3-1.rhel.7.x86_64 1/1
Verifying : powershell-6.2.3-1.rhel.7.x86_64 1/1
Installed:
powershell-6.2.3-1.rhel.7.x86_64
Complete!
[sabi@localhost ~]$

Use the following command to get more information about powershell package.

[sabi@localhost ~]$ rpm -qi powershell
Name : powershell
Version : 6.2.3
Release : 1.rhel.7
Architecture: x86_64
Install Date: Fri 27 Dec 2019 01:49:13 PM PKT
Group : shells
Size : 156967268
License : MIT License
Signature : RSA/SHA256, Wed 11 Sep 2019 03:16:07 AM PKT, Key ID eb3e94adbe1229cf
Source RPM : powershell-6.2.3-1.rhel.7.src.rpm
Build Date : Wed 11 Sep 2019 03:11:50 AM PKT
Build Host : e7b300f89b4a
Relocations : /
Packager : PowerShell Team [email protected]
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.

Step 3: Start and Use PowerShell on CentOS / RHEL 7 / 8

[sabi@localhost ~]$ pwsh
PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /home/sabi>

Now, try to run few commands to verify our Installation.

PS /home/sabi> pwd
Path
/home/sabi
PS /home/sabi> mkdir /tmp/test
PS /home/sabi> cd /tmp/test
PS /tmp/test> 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 854 alsactl
0 0.00 0.97 0.02 1993 …93 at-spi-bus-laun
0 0.00 0.96 0.01 2672 …72 at-spi-bus-laun
0 0.00 0.00 0.01 2001 …93 at-spi2-registr
0 0.00 0.44 0.03 2680 …72 at-spi2-registr
0 0.00 0.00 0.00 407 0 ata_sff
0 0.00 0.41 0.01 1077 …77 atd
0 0.00 0.30 0.06 815 815 auditd
0 0.00 0.75 0.11 850 850 avahi-daemon
0 0.00 0.03 0.00 950 850 avahi-daemon
0 0.00 3.57 0.06 4196 …96 bash
0 0.00 1.38 0.03 2045 …45 boltd
0 0.00 0.29 0.06 874 873 chronyd
0 0.00 0.97 0.13 2145 …45 colord
0 0.00 0.00 0.00 13 0 cpuhp/0
0 0.00 0.48 0.20 1091 …91 crond
0 0.00 0.00 0.00 24 0 crypto
0 0.00 0.79 0.05 1063 …63 cupsd
0 0.00 3.22 1.81 855 855 dbus-daemon
0 0.00 0.88 0.20 1602 …02 dbus-daemon
--More--

That is enough to substantiate our PowerShell functioning on CentOS / RHEL 8. Now you can make use of PowerShell to perform various functions & scripts.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article