Skip to main content

RHEL: Install Powershell Core

Illustration: Microsoft loves Linux

Check if Powershell Core is installed by trying running pwsh command.

[tuyendq@rhel1 ~]$ pwsh
-bash: pwsh: command not found
[tuyendq@rhel1 ~]$ sudo yum install -y powershell
Loaded plugins: product-id, search-disabled-repos, subscription-manager
epel/x86_64/metalink                                     |  22 kB     00:00
epel                                                     | 4.7 kB     00:00
(1/3): epel/x86_64/updateinfo                              | 986 kB   00:00
(2/3): epel/x86_64/primary_db                              | 6.6 MB   00:00
(3/3): jdoss-wireguard/x86_64/primary_db                   | 3.8 kB   00:01
No package powershell available.
Error: Nothing to do
[tuyendq@rhel1 ~]$ curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    400      0 --:--:-- --:--:-- --:--:--   400
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/7/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
[tuyendq@rhel1 ~]$ sudo yum install -y powershell                               Loaded plugins: product-id, search-disabled-repos, subscription-manager
packages-microsoft-com-prod                              | 2.9 kB     00:00
packages-microsoft-com-prod/primary_db                     | 162 kB   00:00
Resolving Dependencies
--> Running transaction check
---> Package powershell.x86_64 0:6.2.0-1.rhel.7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch      Version           Repository                      Size
================================================================================
Installing:
 powershell    x86_64    6.2.0-1.rhel.7    packages-microsoft-com-prod     55 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 55 M
Installed size: 55 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/packages-microsoft-com-prod/packages/powershell-6.2.0-1.rhel.7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for powershell-6.2.0-1.rhel.7.x86_64.rpm is not installed
powershell-6.2.0-1.rhel.7.x86_64.rpm                       |  55 MB   00:10
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) "
 Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
 From       : https://packages.microsoft.com/keys/microsoft.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : powershell-6.2.0-1.rhel.7.x86_64                             1/1
  Verifying  : powershell-6.2.0-1.rhel.7.x86_64                             1/1

Installed:
  powershell.x86_64 0:6.2.0-1.rhel.7

Complete!
[tuyendq@rhel1 ~]$

Let's start powershell by running pwsh command and check system up time with new Get-Uptime cmdlet

[tuyendq@rhel1 ~]$ pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/tuyendq> Get-Uptime

Days              : 93
Hours             : 11
Minutes           : 47
Seconds           : 55
Milliseconds      : 0
Ticks             : 80776750000000
TotalDays         : 93.4916087962963
TotalHours        : 2243.79861111111
TotalMinutes      : 134627.916666667
TotalSeconds      : 8077675
TotalMilliseconds : 8077675000


PS /home/tuyendq>

Check Powershell version by echoing built-in variable $PSVersionTable

PS /home/tuyendq> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Linux 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov …
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /home/tuyendq>

Popular posts from this blog

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.