Installing Powershell Core

I want to celebrate the new Powershell Core edition by showing you how simple is installing it! 

Installing PowerShell Core on Windows

The first step is getting the installer from GitHub: https://github.com/PowerShell/Powershell  and choose the right one for your operating system, most probably an MSI installer for Windows (x64).

The latest version is 6.0.1 and has been released Jan 25th, 2018.  Use this link to always get the latest.

Second step. Once downloaded, (always) read the instructions provided.

Third step. Launch the installer, remember to run it as a local administrator.

   

We suggest you tick the checkbox “Launch PowerShell” so you can quickly check the result.

Installing PowerShell Core on Linux

The process of installing PowerShell core on Linux can be slightly different according to the Linux distribution that you’re using.

Let’s start from the release page: https://github.com/PowerShell/PowerShell/releases 

In this article we will show you the process for installing PowerShell Core on Centos 7.
Usually, I prefer to pack everything into a single bash script (“install-powershell-core.sh”) all the commands and dependencies:

#/bin/bash

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

# Install PowerShell
sudo yum install -y powershell

# Start PowerShell
pwsh

Let’s run the script and see the result!

[root@VM-CENTOS ~]# ./install-powershell-core.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    226      0 --:--:-- --:--:-- --:--:--   225
[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
Loaded plugins: fastestmirror
base                                                                                             | 3.6 kB  00:00:00
docker-ce-stable                                                                                 | 2.9 kB  00:00:00
extras                                                                                           | 3.4 kB  00:00:00
packages-microsoft-com-prod                                                                      | 2.9 kB  00:00:00
updates                                                                                          | 3.4 kB  00:00:00
(1/4): extras/7/x86_64/primary_db                                                                | 145 kB  00:00:00
(2/4): docker-ce-stable/x86_64/primary_db                                                        |  11 kB  00:00:00
(3/4): packages-microsoft-com-prod/primary_db                                                    |  42 kB  00:00:00
(4/4): updates/7/x86_64/primary_db                                                               | 5.3 MB  00:00:02
Determining fastest mirrors
 * base: ftp.swin.edu.au
 * extras: ftp.swin.edu.au
 * updates: ftp.swin.edu.au
Resolving Dependencies
--> Running transaction check
---> Package powershell.x86_64 0:6.0.0-1.rhel.7 will be installed
--> Processing Dependency: libicu for package: powershell-6.0.0-1.rhel.7.x86_64
--> Processing Dependency: libunwind for package: powershell-6.0.0-1.rhel.7.x86_64
--> Running transaction check
---> Package libicu.x86_64 0:50.1.2-15.el7 will be installed
---> Package libunwind.x86_64 2:1.2-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                 Arch                Version                     Repository                                Size
========================================================================================================================
Installing:
 powershell              x86_64              6.0.0-1.rhel.7              packages-microsoft-com-prod               49 M
Installing for dependencies:
 libicu                  x86_64              50.1.2-15.el7               base                                     6.9 M
 libunwind               x86_64              2:1.2-2.el7                 base                                      57 k

Transaction Summary
========================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 56 M
Installed size: 73 M
Downloading packages:
(1/3): libunwind-1.2-2.el7.x86_64.rpm                                                            |  57 kB  00:00:00
(2/3): libicu-50.1.2-15.el7.x86_64.rpm                                                           | 6.9 MB  00:00:07
powershell-6.0.0-1.rhel.7.x86_ FAILED                                          =====- ]  115 B/s |  54 MB  05:33:13 ETA
https://packages.microsoft.com/rhel/7/prod/powershell-6.0.0-1.rhel.7.x86_64.rpm: [Errno 12] Timeout on https://packages.microsoft.com/rhel/7/prod/powershell-6.0.0-1.rhel.7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-prod/packages/powershell-6.0.0-1.rhel.7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for powershell-6.0.0-1.rhel.7.x86_64.rpm is not installed
(3/3): powershell-6.0.0-1.rhel.7.x86_64.rpm                                                      |  49 MB  00:00:07
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   454 kB/s |  56 MB  00:02:06
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
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
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libicu-50.1.2-15.el7.x86_64                                                                          1/3
  Installing : 2:libunwind-1.2-2.el7.x86_64                                                                         2/3
  Installing : powershell-6.0.0-1.rhel.7.x86_64                                                                     3/3
  Verifying  : 2:libunwind-1.2-2.el7.x86_64                                                                         1/3
  Verifying  : powershell-6.0.0-1.rhel.7.x86_64                                                                     2/3
  Verifying  : libicu-50.1.2-15.el7.x86_64                                                                          3/3

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

Dependency Installed:
  libicu.x86_64 0:50.1.2-15.el7                               libunwind.x86_64 2:1.2-2.el7

Complete!
PowerShell v6.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

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

PS /root>

This the end result:

Happy PowerShell!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.